Skip to content

Commit e2dea8a

Browse files
authored
Update 1-objects-and-references.md
I made the correction to the code example so that the print statement in the if-else block produces a readable output exactly as the sample-output says, originally the code did not print anything legible because the object attributes names were not being used, and there is not a __str__ method in the class definition.
1 parent 0cb4ce4 commit e2dea8a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

data/part-9/1-objects-and-references.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,14 +865,14 @@ pascal = Person("Blaise Pascal", 1623)
865865
grace = Person("Grace Hopper", 1906)
866866

867867
if older_than(muhammad, pascal):
868-
print(f"{muhammad} is older than {pascal}")
868+
print(f"{muhammad.name} is older than {pascal.name}")
869869
else:
870-
print(f"{muhammad} is not older than {pascal}")
870+
print(f"{muhammad.name} is not older than {pascal.name}")
871871

872872
if older_than(grace, pascal):
873-
print(f"{grace} is older than {pascal}")
873+
print(f"{grace.name} is older than {pascal.name}")
874874
else:
875-
print(f"{grace} is not older than {pascal}")
875+
print(f"{grace.name} is not older than {pascal.name}")
876876
```
877877

878878
<sample-output>

0 commit comments

Comments
 (0)