Python 3.x 如何将整数放入此列表中

Python 3.x 如何将整数放入此列表中,python-3.x,Python 3.x,我很难找到在不使用列表函数的情况下如何向列表中添加整数或字符串的方法,有人能帮我吗 def add(insert, place): list1 = [1, 2, 3, 4, 5] list1[insert:place] return(list1) insert = int(input("what integer would you like to insert?")) place = int(input("where do you want it put")) list

我很难找到在不使用列表函数的情况下如何向列表中添加整数或字符串的方法,有人能帮我吗

def add(insert, place):
    list1 = [1, 2, 3, 4, 5]
    list1[insert:place]
    return(list1)

insert = int(input("what integer would you like to insert?"))
place = int(input("where do you want it put"))
list1 = p1_function.add(insert, place)
print (list1)

如果要在特定位置插入元素,可以使用list.insert(位置,元素)。请看这里: