Am asked to create a list with items. Am able to add values to list and determine size, but cannot get user input of index to work. Faulty code inserts given value to end of list and None appears in list in weird index. I've attached a screenshot of the console. Thanks. Edit: Append returns none. adjpos = pos - 1 replaces adjpos = pos + 1
# add an item to the list
def add():
i = input("How many items will you add? ")
i = int(i)
for element in range(i):
List.append(input("Add item: "))
print(List)
def insertItemByPosition():
pos = int(input("Select insert location: "))
adjpos = pos + 1
item = List.append(input("Insert item: "))
List.insert(adjpos, item)
print("Revised list: " + str(List))
def main():
add()
insertItemByPosition()
main()