[英]TypeError: 'float' object is not iterable when attempting to choose specific objects from a float list
Good morning everyone, I'm sorry if this question is a duplicate, but I tried to search for this question and can't find any good answer so I'm asking one myself.大家早上好,如果这个问题是重复的,我很抱歉,但我试图搜索这个问题,但找不到任何好的答案,所以我自己问一个。
Basically,基本上,
AccessoriesPrice = (0.00, 50.00, 19.99, 15.99)
for count,(case) in enumerate((AccessoriesPrice[1])):
print(count,"|",case,">>")
I'm currently programming a test app that uses lists as a way to store lists of available phones and accessories and their prices, and then outputs them in a menu, which then prompts them to choose a number, which eventually goes to use the numbers in the lists with stored input numbers in variables.我目前正在编写一个测试应用程序,它使用列表来存储可用手机和配件及其价格的列表,然后将它们输出到菜单中,然后提示他们选择一个数字,最终使用这些数字在变量中存储输入数字的列表中。 Kind of like
AccessoriesPrice[1]
This code above is part of it.有点像
AccessoriesPrice[1]
上面的代码是其中的一部分。
For some reason, when I run the code to the terminal, it says TypeError: 'float' object is not iterable
, and I kinda understand what does the error mean, but I wanted to know if there could be a way where I can grab a specific number from the list with its index number without dealing with this error.出于某种原因,当我将代码运行到终端时,它说
TypeError: 'float' object is not iterable
,我有点明白错误的含义,但我想知道是否有办法可以抓住列表中的特定数字及其索引号,而不处理此错误。 Thank you for answering this question谢谢你回答这个问题
Remove the [1] from it.从中删除 [1]。
AccessoriesPrice = (0.00, 50.00, 19.99, 15.99)
for count,(case) in enumerate((AccessoriesPrice)):
print(count,"|",case,">>")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.