0

add and remove strings to lists ...

List=[] word=input("Enter word to the List: ") List.append(word) while word != "": word=input("Enter word to the List: ") List.append(word) List.pop() print(List) if word=="": name=input("Enter word to remove: ") if name in List: List.remove(name) else: print("name not found") print("the final list is",List)

15th Sep 2016, 10:23 PM
Edward Quintero
Edward Quintero - avatar
1 Antwort
0
Think how to define the while loop, your code is crashing there, the way you define it is not good while word != "": here is a more simple examples about how to manipulate lists, I thing that could help you to get it right: https://www.dotnetperls.com/list-JUMP_LINK__&&__python__&&__JUMP_LINK
5th Oct 2016, 10:09 AM
Krasimir Vatchinsky
Krasimir Vatchinsky - avatar