-3

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")
Random Davis
  • 6,662
  • 4
  • 14
  • 24
andr3a00
  • 7
  • 2
  • the "rewiew your question" said that my question was ready to be published and then when i tried to it just sent me back to "resolve an error" that wasnt there so, sorry for the thing in the question – andr3a00 Oct 21 '21 at 16:57
  • 3
    `r=int(input("Chose your number from 1 to 10 "))` you need to convert the input string to an int. Right now you are comparing the string `'1'` to the int `1` and they do not compare equal – It_is_Chris Oct 21 '21 at 16:57

1 Answers1

0
    import random
random.seed()

numbers=range(1, 11)

r=int(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")

thanks a lot to It_is_Chris!

andr3a00
  • 7
  • 2