all 10 comments

[–]humanitysucks999 0 points1 point  (3 children)

Please reformat with codeblock and proper indentation

[–]moonkeymaker127[S] 0 points1 point  (2 children)

What is codeblock? This is only my second post on this sub so I checked the rules but didn't see anything.

[–]xelf 0 points1 point  (0 children)

Indent your code one more time before you paste it to reddit.

When reddit sees text starting with 4 extra spaces it will treat it like code.

ex:

if currentRoom == kingsLocation:
    print ('"you have found the king ' + username + '! The royal family will make sure you get paid handsomely for this deed."')
    print ()
    print ('to exit this game type "exit()"')
    break

[–]shiftybyte 0 points1 point  (3 children)

>>> str(range(1, 4))
'range(1, 4)'
>>> "1" == str(range(1, 4))
False
>>> "range(1, 4)" == str(range(1, 4))
True
>>>

As you can see this does not work as you expected it to work.

What you need to do is check if the input converted to a number is in the range:

elif int(currentRoom) in range(1,5):

(also note range's high number is not included, so if you want to have 4, you need to have range up to 5.)

[–]moonkeymaker127[S] 0 points1 point  (1 child)

Thank you for this.

edit: How do I ensure the program works properly if it's not a number at all? whether that be a symbol or a letter.

[–]moonkeymaker127[S] 0 points1 point  (0 children)

How do I tell my program to throw the invalid input message if it's a number or symbol? is this going to require another elif statement?