I'm experimenting with raw_input and it works fine except for my 1st if
statement and my else statement. Whenever I run the code and answer the 2nd question with a raw_input listed after 'League' in the 1st if
statement, it returns both the 1st if's print and the else's print when it should only print the 1st if
. Any idea what's wrong?
name = raw_input('What is your name?\n')
game = raw_input('\nWhat MOBA do you play/have played? \n(The answer ' \
'must be case sensitive i.e. LoL for League and DoTA for y\'know the whole darn thing '\
'is too '\
'darn long to say even though I typed a lot more than the name)\n')
if game in ('League' , 'League of Legends' , 'LoL'):
print '\nYou go girl! '
if game in ('DoTA' , 'DoTA 2' , 'DoTA2'):
print '\nThat\'s cool and all but........ Go play League you dang noob. '
else:
print '\nAre you kidding me? You play %s? I\'m severely disappointed in you %s. You ' \
'should at least be playing ' \
'one of these popular games. \nShame, shame, shame. Go install one. ' % (game, name)
you can always use if
for the first conditional, elif
for any number of other conditionals (if the input is in the second list in your instance) and else
if the input is not in any of those lists, your indentation is also a little messed up,nesting if statements inside each other will only run the nested conditional if the first statement is true, I'd also recommend you use the string.lower()
method on your users input so you don't have to instruct the user to type case-sensitive input and use variables to store those lists so you can reuse them elsewhere in your code..something like this:
name = raw_input('What is your name?\n')
game = (raw_input('\nWhat MOBA do you play/have played?')).lower()
awesomeGames=['league' , 'league of legends' , 'lol']
coolGames=['dota' , 'dota 2' , 'dota2']
if game in awesomeGames:
print '\nYou go girl! '
elif game in coolGames:
print '\nThat\'s cool and all but........ Go play League you dang noob. '
else:
print '\nAre you kidding me? You play %s? I\'m severely disappointed in you %s. You ' \
'should at least be playing ' \
'one of these popular games. \nShame, shame, shame. Go install one. ' % (game, name)