1
I’m having the following build error:
del(alimentos[i]) TypeError: 'str' object doesn't support item deletion
What did I do wrong? I would like to remove the typed item from the list.
My code:
dieta = []
alimentos = ""
comer = ""
while len(dieta) is not 26:
alimentos = input("Qual o alimento? ")
if alimentos == "fim":
break
dieta.append(alimentos)
i = 0
while i <= len(dieta):
comer = input("Qual alimento deseja comer? ")
if comer in dieta:
print("pode comer")
del(alimentos[i])
i += 1
Error in your Antony code. Check print: http://imgur.com/a/6O7gR
– Pigot
I don’t know what went wrong there. I just tested it here.
– Antony Gabriel
The code posted here is really ok, take a look at it running here https://repl.it/HwO4/0
– Henrique Marti
For me keeps giving the error... Nameerror: name 'fish' is not defined, as if I had to define the variable fish that is my input '-'
– Pigot
Are you using my code or are you using yours with some modifications based on mine? If it is the second option try using my code only and see what happens. If it is not the case, I do not know what it is, because here it is quiet.
– Antony Gabriel
I’m using your code. I’d also like to know the problem, because it doesn’t make sense.
– Pigot
Thanks guys, I managed to solve the problem: I updated Python from my PC from 2.7 to 3.6. And I uninstalled Pycharm, deleting everything in the old one, and installed again the latest version by selecting interpreter 3.6 on Pycharm.
– Pigot