I have written the following program for demonstration of list of class objects. It take name and score as input for three objects and then it gets stored into a list and at last the program displays all the information i.e. the name and score associated with the object.
class Info:
def __init__(self, name, score):
self.name = name
self.score = score
def display(self):
print(f"Name :- {self.name}, Score :- {self.score}")
game_info = []
for i in range(3):
n = input("Enter Your Name :- ")
s = int(input("Enter Your Score :- "))
game_info.append(Info(n, s))
print()
for i in range(3):
print(game_info[i].display())
print()
Output :-
Enter Your Name :- a
Enter Your Score :- 1
Enter Your Name :- b
Enter Your Score :- 2
Enter Your Name :- c
Enter Your Score :- 3
Name :- a, Score :- 1
None
Name :- b, Score :- 2
None
Name :- c, Score :- 3
None
The output is showing None
every time I try to print the values. So what should I do to remove it from the program output?