Is there a way to convert a NoneType that the user inputs into a string, in python?
This is my code:
topping = print(input("What topping would you like on your pizza?"))
requested_toppings = []
requested_toppings.append(topping)
print("Adding" + topping + "...")
print("\n Finished Making Your Pizza!")
The error is, Type Error: can only concatenate str (not "NoneType") to str
I have tried using str(topping) between the requested toppings list and the append. What am I doing wrong? Thanks!
>Solution :
You do not need print() around the input function. The input function already prints the message as a prompt. The reason you are getting None is because the print function does not return anything, whereas the input function does.
Here is the corrected code:
topping = input("What topping would you like on your pizza?")
requested_toppings = []
requested_toppings.append(topping)
print("Adding" + topping + "...")
print("\n Finished Making Your Pizza!")