I want it so it will randomly generate a number between 1-10 and the user will input their guess. It will then output if it is right or wrong, after 10 rounds it will tell them how psychic they are. I have done most of it but I cannot get it to randomly generate 10 numbers instead it generates 1 number and you can just input that number and get it correct every time if you find that number
JavaScript
x
21
21
1
import random
2
score=0
3
random=(random.randint(1,10))
4
5
for index in range(10):
6
guess=int(input("Choose a number between 1 and 10:"))
7
if random==guess:
8
score+=1
9
print ("Correct, Next")
10
else:
11
print ("Incorrect, Next")
12
13
if score==10:
14
print("Final score:Super mystic")
15
elif score>=7:
16
print("Final score:Good")
17
elif score>=5:
18
print ("Final score:You need more practice")
19
else:
20
print ("Final score:Dont become a psychic")
21
Advertisement
Answer
You need to put the random=(random.randint(1,10))
inside the for loop for it to change with every loop:
JavaScript
1
4
1
for index in range(10):
2
random=(random.randint(1,10))
3
guess=int(input("Choose a number between 1 and 10:"))
4
Then the rest of the code