I'm trying to write a program that prints a hidden message the user has input. The message should be discovered by reading every 3rd character in the input. For example if I input: "pbaynatnahproarnsm" it should print out the bolded letters, i.e. "python". But it comes up with this:
Message? pbaynatnahproarnsm
p y t h o n Traceback (most recent call last):
File "program.py", line 4, in <module>
print(msg[x], end= " ")
IndexError: string index out of range
Here is the code
x = 0
msg = input("Message? ")
for i in msg:
print(msg[x], end= " ")
x = x + 3