Python IMDbPY – Getting Person name from searched name

In this article we will see how we can get the person name from the searched list of name, we use search_name method to find all the related names.

search_name method returns list and each element of list work as a dictionary i.e. they can be queried by giving the key of the data, here key will be name.

Syntax : names[0][‘name’]

Here names is the list return by search_name method and names[0] refer to the first element of list.

Return : It returns string i.e name.



Below is the implementation

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# name of the person
name = "Nawazudin Siddiqui"
   
# searching the name of the person
search = ia.search_person(name)
  
# prinitng whole list
print(search)
  
# printing the name
for i in range(len(search)):
    print(search[i]['name'])

chevron_right


output :

[Person id:1596350[http] name:_Nawazuddin Siddiqui_]
Nawazuddin Siddiqui

Another example :

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# name of the person
name = "Neil Nitin mukesh"
   
# searching the name of the person
search = ia.search_person(name)
  
# printing the name
for i in range(len(search)):
    print(search[i]['name'])

chevron_right


Output :

Neil Nitin Mukesh
Nitin Mukesh
Naman Nitin Mukesh
Nitin Mukesh

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.