Hello I define a class person as following:
class Person(object):
def __init__(self, X, Y):
self.name = X
self.city = Y
names = ['Bob', 'Alex', 'John']
cities = ['New York', 'London', 'Rome']
N = list()
for i in range(0,3):
x = names[i]
y = cities[i]
N.append(Person(x,y))
I want to to check the corresponding cities of a name automatically, something like this
N.name['Bob'].city =
'New York'