我觉得阿什维尼的版本已经做了工作。当我看着你原来的代码,它说这个:
import random
print "\n wlecome to fortune game"
your_fortune = random.randrange(1,8)
if your_fortune == 1: print "your are lucky" else: print "you are not lucky"
raw_input("press enter to exit")
在第四行中,我看到在同一行的if和else语句。这是一个不可思议的语法。使用此:
import random
print "\nWelcome to fortune game"
your_fortune = random.randrange(1,8)
if your_fortune == 1: print "your are lucky"
else: print "you are not lucky"
raw_input("press enter to exit")
或者这样:
import random
print "\nWelcome to fortune game"
your_fortune = random.randrange(1,8)
p = "your are lucky" if your_fortune == 1 else "you are not lucky"
print p
raw_input("press enter to exit")
您的代码看起来不错,发布准确的追踪消息。 –
你使用的是什么版本的Python? –
你的代码适合我 –