是否可以在一个输入中添加不同的值?
这是我现在的代码:
list[]
fruits = input("What are you favorite fruits? Separate each one by comma's.)
list.append(fruits)
print(list)
但结果是:
['Apple,Banana,Strawberry,Orange']
如何使每种水果的结果具有不同的值/每个单一值?就像这样...
['Apple', 'Banana', 'Strawberry', 'Orange']
最佳答案
在安迪发布另一个类似问题的链接后,我找到了答案。
Split an input into two. Python 3
>>> "hello, world".split(',')
['hello', ' world']
关于Python:在一个输入中分离列表中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32567342/