We had a task in school about classes and i got a mistake in my code...
We had the task to create a class person with some methods like getname, getage and so on. Finally there should be a list with some names. The names should be implemented into the class and finally into the empty list "friends" I wrote this, but obviusly there are some mistakes i don't find. Can you help me, please? :) here is my code: # -*- coding: utf-8 -*- """ Created on Mon Jul 17 13:35:51 2017 @author: Anika """ import random class Person(object): def __init__(self,name): self.name=name self.age=int(random.randint(1,100)) def getname(self): return self.name def getage(self): return self.age def birthday(self): self.age +=1 return self.age def __str__(self): return self.name +' is '+ self.age +' years old.' Names=['Harry','Ron','Hermoine','Ginny','Hedwig'] Friends=[] i=0 while i<len(Names): j=Person(Names[i]) Friends.append(j) print (Friends) i+=1