TelluricCoder
TelluricCoder

Reputation: 11

How to combine a print line into one line with an input line?

I'm using Python 3.10 and need help to combine a print line into one line with an input line. This is what I got:

for day in range (1, 6):
    print("Enter the amount of bugs collected on day", day)
    num_bugs_collected = int(input())
    total_bugs += num_bugs_collected

print("You collected a total of", total_bugs, "bugs.")

I need to combine the second and third lines.

Upvotes: 1

Views: 57

Answers (1)

Ben Grossmann
Ben Grossmann

Reputation: 4827

Here's one way to do that.

for day in range (1, 6):
    num_bugs_collected = int(input(f"Enter the amount of bugs collected on day {day}\n"))
    total_bugs += num_bugs_collected

print("You collected a total of", total_bugs, "bugs.")

Upvotes: 1

Related Questions