Jordan8 (1) [Avatar] Offline
#1
Is this normal? (right here)

python 2.7(Sun, 4 Jul 2010 )
and
IronPython .NET (IronPython Tool for Visual Studio 2010), http://ironpython.net/



from random import choice

cave_numbers = range(1,21)
wumpus_location = choice(cave_numbers)
wumpus_friend_location = choice(cave_numbers)
player_location = choice(cave_numbers)
while (player_location == wumpus_location or
player_location == wumpus_friend_location) :
player_location = choice(cave_numbers) #1

print "Welcome to Hunt the Wumpus!"
print "You can see", len(cave_numbers), "caves"
print "To play, just type the number"
print "of the cave you wish to enter next" #2

while True: #3
print "You are in cave", player_location
if (player_location == wumpus_location - 1 or
player_location == wumpus_location + 1):
print "I smell a wumpus!" #4
if (player_location == wumpus_friend_location - 1 or
player_location == wumpus_friend_location + 1):
# right here(This "print" must be one space to there right? )
print "I smell an even stinkier wumpus!"
# right here
print "Which cave next?"
player_input = raw_input('>')
if (not player_input.isdigit() or
int(player_input) not in cave_numbers):
print player_input, "is not a cave!" #5
else:
player_location = int(player_input)
if player_location == wumpus_location:
print "Aargh! You got eaten by a wumpus!"
break #6
if player_location == wumpus_friend_location:
print "Aargh! You got eaten by the wumpus' friend!"
break

raw_input('Ha!')

Jordan Powell
anthony.briggs (30) [Avatar] Offline
#2
Re: Listing 2.3
Hi Jordan,

It's hard to tell since all your indentation has been eated, but what that section should look like is:

if (player_location == wumpus_friend_location - 1 or
.....player_location == wumpus_friend_location + 1):
....# right here(This "print" must be one space to there right? )
....print "I smell an even stinkier wumpus!"

ie. with the player_location parts lined up, and the print statement indented 4 spaces.

Does that help?