random.random无效语法
问题描述:
我正在Python上做一个简单的游戏,它使用random.random()功能,但是在脚本末尾,我在random.random()上得到了一个无效的语法. 我不是很有才华,解决方法可能很简单,但是我不明白为什么它会向我发送错误,非常感谢您的帮助.
I'm doing a simple game on Python that uses a random.random() feature, however I'm getting a Invalid Syntax on random.random() in the end of the script. I am not very talented and probably the solution is very simple, but I just don't get why is it sending me the error, I would very much appreciate your help.
#Text based game
import time
import os
import sys
import random
start_time = time.clock()
def cls():
os.system(['clear','cls'][os.name == 'nt'])
Class = "warrior"
print("Welcome to THE Game, the most epic text based Game you have ever played.") #Please make a better name, thanks :)
start = input("Are you ready to start?: ")
cls()
if start == 'yes':
name = input("What is your name?: ")
cls()
print("Welcome young traveler, here you will experience like nothing you've experienced before (Ha, as if anything is new these days), but remember ", name,", no one can protect you from this point on.")
input("Press any key to continue: ")
cls()
print("Please choose a character.")
print("")
else:
print random.random()
input()
quit()
答
在print
周围缺少()
,该行应显示为:
You are missing ()
around print
, the line should read:
print(random.random())