Reputation: 27
Everything else in my code is working, but every time it asks to add a new item to the list, python also returns 'None' I'm trying to get rid of this, any help would be appreciated.
This is my code:
#Welcome
name = input("What is your name? ")
print("Welcome %s to your shopping list" %name)
#Adding to the list
shoppingList = []
while True:
new_item = input(print("Please enter an item of your shopping list and type END when you have entered all of your items: "))
if new_item == "END": break
shoppingList.append(new_item)
length = len(shoppingList)
print("Your shopping list is", length, "item(s) long.")
shoppingList.sort
print("This is your list: ", shoppingList)
#Prompting the user to change list if necessary
change = input(print("Is there anything you wish to change?"))
if 'No' in change: print("Great.")
else:
delete = input(print("Which item would you like to replace?"))
shoppingList.remove(delete)
replace = input(print("What would you like to replace it with?"))
shoppingList.append(replace)
print("This is your new list: ", shoppingList)
Upvotes: 0
Views: 98
Reputation: 251041
You're calling print()
inside of input()
, and print()
returns None
. Simply pass the string to input()
:
input("Is there anything you wish to change?")
Also, shoppingList.sort
won't do anything. You need to call it properly: shoppingList.sort()
.
Upvotes: 5