-1

Let's say I have a class that look something like this:

class helloworld():
     def __init__(self):
          self.hello1 = 'Hello World'
          self.hello2 = 'Hola Mundo'
          self.hello3 = 'Hej Verden'
          self.hello4 = 'Konnichiwa Sekai'

Is there a way I can loop or call these four strings from a dummy variable? So something like:

for i in (range(1,5)):
     print(self.helloi)

The trouble I'm facing is that the i becomes part of the name instead of 1-4.

0 Answers0