Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class Character:
- def __init__(self, name, surname, age, gender):
- self.name = name
- self.surname = surname
- self.age = age
- self.gender = gender
- def print_char_info(self):
- # Counts the length of the characters of both the name and surname attributes
- lineLength = len(self.surname + self.name)
- # This adds 7 so that it can match the total length with the Name: at the bottom where it is being printed
- lineLengthAdd = lineLength + 7
- charInfo = len("Character Info:")
- print("Character Info:")
- # Prints - that is of equal length to the charInfo variable
- for i in range(charInfo):
- print("-", end="")
- #print()
- #print("Name:")
- #for i in range(lineLengthAdd):
- # print("-", end="")
- print()
- print(f"Name: {self.surname} {self.name}")
- # Does the same as the previous for loops
- for i in range(lineLengthAdd):
- print("-", end="")
- print()
- print(f"Gender: {self.gender}")
- for i in range(lineLengthAdd):
- print("-", end="")
- print()
- print(f"Age: {self.age}")
Advertisement
Add Comment
Please, Sign In to add comment