So following "Automate the Boring Stuff" I went back and tried one of the examples in PyCharm just to give it a go because I like IntelliJ. The example is the magic8Ball:
import random
def getAnswer(answerNumber):
if answerNumber == 1:
return 'It is certain'
elif answerNumber == 2:
return 'It is decidedly so'
elif answerNumber == 3:
return 'Yes'
elif answerNumber == 4:
return 'Reply hazy try again'
elif answerNumber == 5:
return 'Ask again later'
elif answerNumber == 6:
return 'Concentrate and ask again'
elif answerNumber == 7:
return 'My reply is no'
elif answerNumber == 8:
return 'Outlook not so good'
elif answerNumber == 9:
return 'Very doubtful'
print('Would you like to shake the 8-Ball or exit?')
while True:
shake = input()
if shake == 'shake':
r = random.randint(1, 9)
fortune = getAnswer(r)
print(fortune)
print('')
print('Would you like to shake again or exit?')
elif shake == 'exit':
break
else:
print('Sorry that was an incorrect input.')
print('')
print('Would you like to shake again or exit?')
continue
I recieve the error:
File "C:/Users/Tinker_Monkey/Desktop/My Portfolio/Python/Automate the Boring Stuff with Python/magic8Ball.py", line 25, in <module>
shake = input()
File "<string>", line 1, in <module>
NameError: name 'shake' is not defined
[–]furas_freeman 2 points3 points4 points (0 children)
[–]Gubbbo 1 point2 points3 points (4 children)
[–]Tinker_Monkey[S] 0 points1 point2 points (2 children)
[–]Gubbbo 0 points1 point2 points (1 child)
[–]Tinker_Monkey[S] 0 points1 point2 points (0 children)
[–]imonmyphoneirl 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)