I am trying to make my variables "flexible" using a for loop, but I can't get it to work.
I want it to ouput the messages I wrote, I tried 'message_' without the '' but that just gives an error that it's not an actual variable.
Thanks in advance for the help.
Here is my code snippit:
message_1 = 'This is message 1.'
message_2 = 'This is message 2.'
message_3 = 'This is message 3.'
message_4 = 'This is message 4.'
for x in range(1, 5):
print('message_' + str(x))
Output:
Message_1
Message_2
Message_3
Message_4