random.random invalid syntax [duplicate]

放肆的年华 提交于 2020-07-20 06:45:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!