问题
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()
回答1:
You are missing ()
around print
, the line should read:
print(random.random())
来源:https://stackoverflow.com/questions/32977276/random-random-invalid-syntax