Jul-20-2022, 05:15 PM
Have a list of actors. Asking the user to enter an actor name that exists in the list. Although entering an existing name in the list, the code says it does not exist in the list. The "counter" function shows 0, "boolean" operator is False.
Why getting this error ?
note: If I enter the actor name manually, the code can find the name in the list. So I tried to check the data type of "search_person" function and it returns "class". I tried to convert it to list by using list() function but also getting error.
Asking for user input
If enter the "actor" name in the code like below, the code can find it in the list however I need to ask the user input like above
Output for manually entering the actor name in the code (Successful)
Why getting this error ?
note: If I enter the actor name manually, the code can find the name in the list. So I tried to check the data type of "search_person" function and it returns "class". I tried to convert it to list by using list() function but also getting error.
Asking for user input
from imdb import Cinemagoer ia=Cinemagoer() actors=['Natalie Biggs','Daniel Crossley','Jaye Davidson','Tania Emery','Titus Forbes-Adam','Anthony Houghton','Jane Milligan'] # search for an actor in actors list people = ia.search_person(input('enter an actor/actress name that exists in the list above: ')) main_person=people[0] ia.update(main_person) print(actors.count(main_person)) print(main_person in actors)Output of asking to user:
Output:enter an actor/actress name that exists in the list above: Natalie Biggs
0
False
Process finished
> with exit code 0
If enter the "actor" name in the code like below, the code can find it in the list however I need to ask the user input like above
from imdb import Cinemagoer ia=Cinemagoer() actors=['Natalie Biggs','Daniel Crossley','Jaye Davidson','Tania Emery','Titus Forbes-Adam','Anthony Houghton','Jane Milligan'] actor='Natalie Biggs' print(actors.count(actor))
Output for manually entering the actor name in the code (Successful)
Output:1
Process finished with exit code 0