我无法弄清楚如何增加我的用户输入。
我尝试将“int”变量的函数更改为“float”和“str”,但我似乎无法弄清楚。我的代码:
pops = input("Enter your favorite pop: ")
cost = input("Enter how much they cost: ")
how_many = input("Enter how many pops you have: ")
print('My favorite pop is ' + pops + '!')
print('They cost about ' + cost + ' dollars.')
print('I have about ' + how_many + ' pops!')
result = str(cost) * str(how_many)
print("You have spent over " + result + " dollars on pops!")
我有下一个错误:
结果 = str(cost) * str(how_many) TypeError:不能将序列乘以“str”类型的非整数
慕村225694
函数式编程
慕后森
相关分类