How to print object of a class in Python

1 Answer

0 votes
class User:
   def __init__(self, name, website, password):
      self.name = name
      self.website = website
      self.password = password
        
   def __str__(self):
      return f"My name is {self.name} and I am the owner of {self.website}."

user1 = User("Luna", "qaqa.com", "2fj$D5")
user2 = User("Emma", "abegede.com", "8f@GD12")

print(user1) 
print(user2)



'''
run:

My name is Luna and I am the owner of qaqa.com.
My name is Emma and I am the owner of abegede.com.

'''

 



answered Jan 13 by avibootz
...