jeudi 21 octobre 2021

how to check if int input is in a list?

6 random numbers from 1 to 10(they must be all different) and if the input is in the list of random number "you won" should be printed, but it doesn't happen.

This is what I have:

import random
numbers=range(1, 11)
r=input("Chose your number from 1 to 10 ")
a=random.sample(numbers, k=6)
print(a)
if r in a:
    print("you won!")
else:
    print("you lose")

Aucun commentaire:

Enregistrer un commentaire