Nov-12-2018, 01:47 AM
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.
The first problem is that you have getvalue serving two purposes: The name of the function and the name of the value it creates. Second, the value it creates exists only in the function. You need to return it to access it outside the function:
Note that there is a tie whenever the human and computer choose the same, not just when they both choose 1 (human == computer). Also triple quotes (""") can be used to start and end a multi-line string.
The first problem is that you have getvalue serving two purposes: The name of the function and the name of the value it creates. Second, the value it creates exists only in the function. You need to return it to access it outside the function:
def getvalue(cpu): if cpu <= 300: value = 1 return value computer = getvalue(cpu)Note that the easiest way to get a random value from 1 to 3 is
random.randint(1, 3)
. Then you don't need a separate function. Especially because getvalue as set up now will cause an error if cpu is over 300.Note that there is a tie whenever the human and computer choose the same, not just when they both choose 1 (human == computer). Also triple quotes (""") can be used to start and end a multi-line string.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures