2 回答

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊
只需將代碼放入循環(huán)中:
while True:
if remove_char1_attr1 = 'yes':
char1_attr1.remove(min(char1_attr1))
char1_attr1_5 = random.randint(1,6)
char1_attr1.append(char1_attr1_5)
print("The numbers are now as follows: " +char1_attr1 )
elif remove_char1_attr1 = 'no'
break
else:
#incorrect_response()
print("Incorrect")
然后它將運(yùn)行直到“否”remove_char1_attr1

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊
您可以嘗試循環(huán),而它不是是或否
while remove_char1_attr1 not in ('yes', 'no'):
if remove_char1_attr1 = 'yes':
char1_attr1.remove(min(char1_attr1))
char1_attr1_5 = random.randint(1,6)
char1_attr1.append(char1_attr1_5)
print("The numbers are now as follows: " +char1_attr1 )
elif remove_char1_attr1 = 'no'
break
else:
incorrect_response()
添加回答
舉報(bào)