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
Python3
import imdb
ia = imdb.IMDb()
name = "Nawazudin Siddiqui"
search = ia.search_person(name)
print (search)
for i in range ( len (search)):
print (search[i][ 'name' ])
|
output :
[Person id:1596350[http] name:_Nawazuddin Siddiqui_]
Nawazuddin Siddiqui
Another example :
Python3
import imdb
ia = imdb.IMDb()
name = "Neil Nitin mukesh"
search = ia.search_person(name)
for i in range ( len (search)):
print (search[i][ 'name' ])
|
Output :
Neil Nitin Mukesh
Nitin Mukesh
Naman Nitin Mukesh
Nitin Mukesh