我已经看过这篇关于可迭代python错误的帖子了:
但这是关于"无法分配可迭代"的错误.我的问题是为什么python告诉我:
"list.py", line 6, in <module>
reversedlist = ' '.join(toberlist1)
TypeError: can only join an iterable
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么!我正在关注这个帖子:
特别是这个答案:
>>> s = 'This is a string to try'
>>> r = s.split(' ')
['This', 'is', 'a', 'string', 'to', 'try']
>>> r.reverse()
>>> r
['try', 'to', 'string', 'a', 'is', 'This']
>>> result = ' '.join(r)
>>> result
'try to string a is This'
Run Code Online (Sandbox Code Playgroud)
并适配代码使其具有输入.但当我跑它时,它说上面的错误.我是一个完整的新手所以,请你告诉我错误信息的含义以及如何解决它.
代码如下:
import re
list1 = input ("please enter the list you want to print")
print …Run Code Online (Sandbox Code Playgroud)