I'm trying to get my code to say an action five times in a row. Here's what I have so far:
```python
people = input("People: ")
action = input("Action: ")
print(f'And the {people} gonna {action}')
```
How can I modify it to repeat the action five times?
2 Answers
A simple way is to just multiply the string you want by five, like this: `f'{action}' * 5`. Then, you can adjust your print statement to use that:
```python
print(f"And the {people} gonna " + f"{action}" * 5)
```
How do I add spaces between all the `{action}` outputs?
You can use a for loop for this. Just use `for i in range(5): print(action)` to repeat it five times. If you want it in context with the people input, this is how it would look.
```python
for i in range(5):
print(f'And the {people} gonna {action}')
```
You can use `join` for that! Here’s how:
```python
print(f"And the {people} gonna {' '.join([action] * 5)})
```