[Solved] Rainbow Array on Python


Here is a basic example.

rainbow = ['Program Ended', 'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo']

user_input = int(input("Please select a number between 1 and 6: "))

if user_input > 0 and user_input < 7:
    print(rainbow[user_input])
else:
    print("Program ended")

To capture a user’s input, you simply invoke: input() function.

To access an array, you can do so by doing: rainbown[i], where i is the index of the array.

If you want me to clarify anything, please let me know.

solved Rainbow Array on Python