This Python program reads an integer from the user, representing the number of trips.
Using a for loop, it prints the character '7' that many times in the terminal.
This exercise helps reinforce basic loop structures and character repetition in Python.
def print_sevens(n):
for i in range(n):
print("7", end=" ")
print()
# Run the program
trips = int(input("Enter number of trips: "))
print_sevens(trips)
7 7 7 7 7
- The program first reads the number of trips from the user
- A for loop runs for that many iterations
- In each iteration, it prints the character '7' followed by a space
- The result is a single line of repeated '7' characters