Code
I want to input multiple values (see commented line below), so the user can easily search for multiple values and loop can find the values.
How can I change the input to a lists of text, so that the program check everything?
Like this: what_to_look = ['james','tom'].split()
How about 1 per line – when reading it from a file.txt?
I think I am getting a wrong result, post_id is actual id of post URL.
I want to know if and what is the id of specific post py listing their name in file.txt.
With that said, "james kim" should give answers: 5 and 9 but not a 5 and 6.
title = ['james','tom','kim']
post_ids = [5,6,9]
what_to_look = input('Enter Name: ') # convert this like (what_to_look = ['james','tom'] )
# search for the values
if what_to_look in title:
position = title.index(what_to_look)
post_id = post_ids[position]
print('found', post_id)
else:
print('not found')
How can I convert the input into a list like ('james','kim')?
what_to_lookto be a list (if it contains values found intitle)?.split()method, in your caseinput().split()