这是我制作的一款小游戏。简单的规则,玩家必须在我的脑海中确定数字。我稍后会导入随机模块。
print('Hello!, What is your name?')
userName = input()
print(myName + 'Welcome to Guess it! Ralph')
print('You must guess the number that I have in my mind(from 1 to 10) within 5 chances')
myNumber = 3
print('Give your prediction')
for no_of_chances in range(5, 0, -1):
usersPrediction = input()
我在pycharm中运行时遇到此错误: if usersPrediction<我的号码: ^ IndentationError:意外缩进
if usersPrediction < myNumber:
print('It is lower than required,try a higher value')
elif usersPrediction > myNumber:
print('It is higher than required,try a lower value')
elif usersPrediction == myNumber:
print('yahoo!, you did it')
print('You always have a next chance, try it again')
答案 0 :(得分:1)
缩进print('yahoo!, you did it')