This person has posted the SO problem Oct 11, 2020 but is not yet solved.
The code tries to capture input in an array (the name and ages of persons in a persons array). It seems that the name and age captured for the first time is never cleared at all, (even though you can see it changing in the colab), and at the end, for n number of times, the first name and age is printed.
there_is_more_people = True
people = []
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def register_people(there_is_more_people):
while there_is_more_people:
did_you_finish = input("did you finish filling the fields? y/n")[0].lower()
#@markdown ## Fill your data here:
name = "mary" #@param {type:"string"}
age = 21#@param {type:"integer"}
new_person = Person(name, age)
people.append(new_person)
if did_you_finish == 'y':
people.append(new_person)
input_there_is_more_people = input("there is more people? y/n")[0].lower()
if input_there_is_more_people == 'y':
there_is_more_people = True
name = None
age = None
else:
there_is_more_people = False
for i in people:
print("These are the people you registered:")
print(i.name)
register_people(there_is_more_people)
No comments:
Post a Comment