如果条件不起作用!蟒蛇

时间:2018-02-23 03:54:15

标签: python conditional

我正在尝试使用python,我编写了这款游戏。 if条件似乎并不像我想要的那样工作。如果在语义或任何事情上存在误解,请教育我。 PS:我在python 3上运行了这个

import time
from random import randint

def tambola():

    token = input("Enter a value between 1 to 2 :  ")
    print('')
    print("Computer generating number",end='')
    time.sleep(1)
    print(".",end='')
    time.sleep(1)
    print(".")
    time.sleep(1)

    answer = randint(1,2)
    if(token == answer):  #condition doesnt seem to be working :/
        print("You win")
    else:
        print("Better luck next time")
        print(token,answer)

这是我得到的输出

Enter a value between 1 to 2 :  2

Computer generating number..
Better luck next time
2 2

0 个答案:

没有答案