您可以使用它,只循环一次,然后检查计数器是否可以除以10以打印消息
for i in range(1,100):
num = int(input("Enter an integer: "))
print("The double of",num,"is",2 * num)
if i%10==0:
print('10')
如果您需要无限循环:
i = 1
while True:
num = int(input("Enter an integer: "))
print("The double of",2 * num)
if i%10==0:
print('10')
i+=1
for i in range(1,21)
的结果将是
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
10
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
The double of 50 is 100
10
本文链接:https://www.f2er.com/3061715.html