简体   繁体   中英

Print user inputs in 5 different statements

I`m new to Python.I need to get 2 values(eg Black,White)as user inputs and print it 5 times like below example.

1.Colour for No 1 : Black 2.Colour for No 2 : White 3.Colour for No 3 : White 4.Colour for No 4 : Black 5.Colour for No 5 : White

Use input() to get user input. Use a for loop to repeat 5 times.

for i in range(1,6):

    color = input()
    print(str(i)+". Color for number "+str(i)+": "+color)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM