-4
__author__ = 'Toby'
error = 0 ## Sets a variable that allows a while loop to be used
while error == 0: ## While loop so that the program will keep asking until a valid entry is inputted
try:
number1 = float(input("please enter 1st number")) ## The first number is inputted and stored as a variable
except ValueError: ## Error Capture so the user can try again if invalid entry is enterd
print("Please enter a number, it can be a decimal or an integer")
print("try again")
else:
break
error2 = 0
while True: ## While loop so that the program will keep asking until a valid entry is inpuuted
try:
number2 = float(input("please enter 2nd number")) ## Takes second number and inouts into a different vairable
except ValueError:
print("Please enter a number, it can be a decimal or an integer")
print("try again")
else:
break
error3 = 0
while True: ## While true means,run the loop below so that the user can input a 3rd number,and the prgram will keep asking until it is a valid entry
try:
number3 = float(input("please enter 3rd number"))
except ValueError:
print("Please enter a number, it can be a decimal or an integer")
print("try again")
else:
break
if number1 == number2 and number2 == number3: ## if statement to check that if all numbers are equal then an appropiate action can be carried out
print("SNAP!")
else:
print("Sorry your numbers dotn match. do you want to play again?")
我的任务是做一个蟒蛇游戏,然后有什么更好的办法,我可以做到这一点,以获得更多的分数?我在做GCSE计算机科学。谢谢Python捕捉游戏
我投票结束这个问题作为题外话,因为我们不知道如何才能“获得更多的分数”。 – That1Guy
请尝试询问[代码评论](http://codereview.stackexchange.com/)。如果您的代码是功能性的,他们应该乐于提供样式/优化提示。 – Kevin
您可以从改善拼写开始。 ''对不起,你的号码不匹配,你想再玩一次吗?“有两个字符倒过来,缺少一个首都。 – Mast