I am very new to python. I was testing my little knowledge of python by creating a simple for/if loop.
Here is my code
Code:
#!/usr/bin/python3
matched =[]
count = 0
win_nums = ('1','15','20','31','50')
mynums = input("Enter your numbers: ")
for i in mynums:
if i in win_nums:
count += 1
matched.append(i)
print (f"you mantch {count} numbers. They are {matched}")
When I run it, I get this below
Code:
./lottocheck.py
Enter your numbers: 1 17 25 31 51
you mantch 4 numbers. They are ['1', '1', '1', '1']
It should have given me 1 and 31 with 2 matches.
I tried changing the line from
if i in win_nums: to
if i == win_nums: and I get
Code:
./lottocheck.py
Enter your numbers: 1 17 25 31 51
you mantch 0 numbers. They are []
Any ideas what I am doing wrong. I appreciate any help. Thanks