创建一个列表或元素,其中包含10个数和5个字母。从这个列表或元组中随机选择4个数或
字母,并打印一条消息,指出只要彩票上是这4个数或字母,就中大奖了。
from random import choice
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'a', 'b', 'c', 'd']
lucky_lottery = []
for i in range(4):
value = choice(list1)
lucky_lottery.append(value)
print(f'幸运彩票号是:{lucky_lottery}')
输出:
幸运彩票号是:[8, 2, 5, 4]