I wanted to do this system that will check if fruit is in a list, but I need user input to be in lowercase, so it would not duplicate. But when I do try to use lower() function, it does not really work as planned.
fruits = ['banana', 'orange', 'mango', 'lemon']
new_fruit = input("Input the fruit and system will check if it is there, if it is not, it will add it: ")
new_fruit.lower() #lower function.
if new_fruit in fruits:
print("The fruit has already been added!")
else:
fruits.append(new_fruit)
print("Your fruit was not in the list, it was added, here is new list: ", fruits)
>Solution :
You are calling the function, but you’re not saving it’s return.
Try instead
new_fruit = new_fruit.lower()
Or, more concise:
new_fruit = input("Input the fruit and system will check if it is there, if it is not, it will add it: ").lower()