Python 如何将用户的输入放入列表中?

Python 如何将用户的输入放入列表中?,python,list,Python,List,我一直在尝试制作一个歌曲洗牌器,但我无法将用户的输入放入列表中。我试着把输入输入到列表中,但它不起作用。这是代码。我应该试试什么 songs = list input1 = input('type in the name of a song file you have downloaded') songs = songs + input1 尝试一下: songs = list() inpt = input('type in the name of a song file

我一直在尝试制作一个歌曲洗牌器,但我无法将用户的输入放入列表中。我试着把输入输入到列表中,但它不起作用。这是代码。我应该试试什么

    songs = list
    input1 = input('type in the name of a song file you have downloaded')
    songs = songs + input1
尝试一下:

songs = list()
inpt = input('type in the name of a song file you have downloaded')
songs.append(inpt)

list
是一个函数,因此它需要括号将
歌曲初始化为
[]
。通过使用函数而不是使用加法运算符来追加到列表。您还可以使用
songs=songs+[inpt]

您应该首先执行,因为这是典型的列表操作

歌曲=[]
虽然(正确):
input1=input('输入您下载的歌曲文件的名称')
歌曲=歌曲。追加(输入1)