Python input question!

Asked 1 years ago, Updated 1 years ago, 45 views

Picture shows

a

12chances.Enter a letter:a It appears like this, but the values of a do not appear on the screen 12chances.Enter a letter:a How do I code to show only like this on the screen?

python input

2022-09-21 10:06

1 Answers

This is because you put the input() function inside the print statement.

As you wrote, you need to enter input() to complete the entire string, and then execute the print statement.

a # Input value to pass to the input() function
12 chances. Enter letter: A completed string after passing the input value to the a# input() function

Because the input() function is a function that outputs a string before receiving an input when passed to a parameter, you can use input() itself instead of using print.

count = 12
while count > 0:
    input(str(count) + 'chances. Enter a letter: ')
    count -= 1


2022-09-21 10:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.