Skip to main content
  1. Posts/

What is your favorite colour in Python?

·104 words·1 min

Today I have made a program that asks a user for their favourite colour, then prints out the colour.

In the program I used a function called input() to capture the input from the user, and assign that value into a variable.

Here is the program in Python:

colour = input("What is your favourite colour? ")
print("Your favourite colour is " + colour)

To run the program, copy and paste the two lines above to a file called colour.py, then run it with python3 ./colour.py. Here is the example output:

kodert@nuc:~/dev/python> python3 ./colour.py 
What is your favourite colour? blue
Your favourite colour is blue