【发布时间】:2021-07-26 02:58:24
【问题描述】:
我是 python 新手,我对初学者问题有点困难
Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers
这是我写的代码
sea = 9 , 8 , 8 , 8
list = sea.split(",")
tuple = tuple(list)
print ("List: " ,list)
print ("Tuple: " ,tuple)
但它给了我一个属性错误
AttributeError: 'tuple' object has no attribute 'split'
就是这样,呵呵,感谢您花时间阅读本文,请帮我纠正:0
【问题讨论】:
-
请注意,
sea已经是tuple。
标签: python list object tuples attributeerror