Skip to content
Advertisement

Python, random.randint does not print out

this is the code down below

I am not sure if of the 22 variables it does not guess the number or have I done something wrong

print("pick a number between 1 and 10 and type it down below")
numberone = input()
n1 = random.randint(1,10)
n2 = random.randint(1,10)
n3 = random.randint(1,10)
n4 = random.randint(1,10)
n5 = random.randint(1,10)
n6 = random.randint(1,10)
n7 = random.randint(1,10)
n8 = random.randint(1,10)
n9 = random.randint(1,10)
n10 = random.randint(1,10)
n11 = random.randint(1,10)
n12 = random.randint(1,10)
n13 = random.randint(1,10)
n14 = random.randint(1,10)
n15 = random.randint(1,10)
n16 = random.randint(1,10)
n17 = random.randint(1,10)
n18 = random.randint(1,10)
n19 = random.randint(1,10)
n20 = random.randint(1,10)
n21 = random.randint(1,10)
n22 = random.randint(1,10)
if (n1,n22) == numberone:
  print("i guess your number and it is" + input())

if you are reading this, Thank you so much for just attempting to help someone! you are a good person and are willing to help others

Advertisement

Answer

its very good to explain what you exactly you want to do.

i assume you want to guess the number with 22 attempts and check if any of them got the record.

import random

print("pick a number between 1 and 10 and type it down below")
number = int(input())

if not 0 < number < 11:
    print("you should've entered a number between 1 and 10 :(")    

guesses_result = []

for i in range(22):
    guesses_result.append(random.randint(1, 10))

if number in guesses_result:
   print(f"i guess your number and it is {number}")
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement