python字符串迭代_Python字符串迭代/函数
我需要我的“items”變量將每個項目打印到新行上。我總是在“items”中得到總數,在“total”中得到總數?!翱傆嫛贝蛴〕鑫蚁胍慕Y果,但我希望這些項目單獨打印。在
有什么想法?在def adding_report():
user_input = input("Report Types include All Items ('A') or Total Only ('T')\nChoose Report Type ('A'or'T'):")
items = "\n"
total = 0
while True:
if user_input == 'A'.lower():
user_input1 = input("Input an integer to add to the total or 'Q' to quit: ")
if user_input1.isdigit():
items = int(user_input1)
total += int(user_input1)
continue
elif user_input1 == 'Q'.lower():
print("Items\n", items)
print("Total\n", total)
break
elif user_input1.startswith('q'):
print('Items\n', int(items))
print("Total\n", total)
break
else:
print("Input is not valid")
elif user_input == 'T'.lower():
user_input2 = input("Input an integer to add the total or 'Q' to quit: ")
adding_report()
總結
以上是生活随笔為你收集整理的python字符串迭代_Python字符串迭代/函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 机器人出魔切还是三相_工业机器人常见故障
- 下一篇: python svn库_python实现