Jump to content

Python program that reads a list of names from a file


G+_Nevrin O
 Share

Recommended Posts

A question and an observation:

 

1. I see you wrote a function to do the check to see if the name I want to delete is in the list. I tried replacing with 

 

"if element in namesList"

 

but it didn't work. I thought I'd used that successfully before to check if an element is in a list. Any ideas why it doesn't work here?

 

2. When deleting by index, the pop and message is contained in the same line of code which, when you type in an invalid number, leads to a message like "successfully removed there is no name located..."

Link to comment
Share on other sites

Thanks for finding that bug with the index (it made sense at 4:00am) :P

 

as for the contains function idk why it isn't working for you i actually changed it to your code and it works fine. It actually saved me an entire function worth of code doing that (thank you) I guess I was just treating it like an array and not a list and assumed I had to look at each element.

Link to comment
Share on other sites

 Share

×
×
  • Create New...