'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.



Solution 1:[1]

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.")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ben Grossmann