如何使用oprator输入python向数组添加索引?
这是源代码:如何使用oprator输入python向数组添加索引?,python,typeerror,Python,Typeerror,这是源代码: while (1): num =input("please enter for array or for lunch index array enter\"lunch\"") hh=[] p=int(len(hh)) print(p) print(type(p)) if(num=="lunch"): print(hh) eli
while (1):
num =input("please enter for array or for lunch index array enter\"lunch\"")
hh=[]
p=int(len(hh))
print(p)
print(type(p))
if(num=="lunch"):
print(hh)
elif(num=="end"):
break
else:
cc=0
for cc in p :
hh.append(i,num)
cc+=1
print(hh)
这就是我得到的错误:
Traceback (most recent call last):
File "D:\python project\array.py", line 14, in <module>
for cc in p :
TypeError: 'int' object is not iterable
为什么我会出现打字错误?
请解释什么是iterable…iterable是具有多个项和支持的对象
所以列表、元组、字符串是可编辑的,整数不是您试图迭代整数-什么不清楚?