我有一个数字和阿尔法的混合列表。
import random
def main():
list: ['1','2','3','4','5','6','7','a','b','c']
for count in range (1,5):
serial_no=("serial #: ", count)
totallist=0
from random import choice:
number=choice(list)
print(serial_no+'for the time: '+number)
if number.isdigit() and number<4:
totallist+=int(number) # want to add the first number >4
elif number.isdigit()and number>4:
totallist+=int(number)
elif number.isalpha():
list[9]=0
list[-1]=0
totallist=int(list[9])+int(list[-1]) #I could not add (error) (want to add alpha(as 0) and number after being alpha)
print(totallist)
main()
有什么办法可以将第一个随机数> 4 添加到 number < 4 的总随机数中?
谢谢