Q. Lottery Analysis: You can use a loop to see how hard it might be to win the kind of lottery you just modeled. Make a list or tuple called my_ticket. Write a loop that keeps pulling numbers until your ticket wins. Print a message reporting how many times the loop had to run to give you a winning ticket.
why is it not working??
My code
why is it not working??
My code
from random import choice
list1 = [7, 'z', 10, 3, 4, 1, 'a', 6, 'c', 'b', 5, 8, 'j', 9, 2]
num1 = (choice(list1))
num2 = (choice(list1))
num3 = (choice(list1))
num4 = (choice(list1))
print(f"Any letter matching {num1, num2, num3, num4} these numbers will win the lottery.")
my_ticket = [0]
for num in my_ticket:
num = choice(list1)
my_ticket.append(num)
if num1 and num2 and num3 and num4 in my_ticket:
print('You have won the lottery.')
break
print(my_ticket)
Larz60+ write Aug-09-2021, 08:01 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
