0
Two lines needlessly used in else statement. Help shorten it
#verifying my shopping list i=input() shopping=['tomato', 'potato', 'onion'] j=2 if i in shopping: print('its there') #remove duplication in next two line else: shopping+=[j+1] shopping [j+1]=i print(shopping)
2 ответов
+ 8
#you can do this:
shopping.append(i)
#however, that's asuuming you don't want shopping+=[j+1] , I don't know why you'd want to add the number three to it...
+ 1
thank you, I seem to have forgotten why I couldn't think of append or insert commant