I'm trying to figure out how to modify my code so that it prints a specific action five times in a row. Here's what I currently have:
```python
people = input("People: ")
action = input("Action: ")
print(f'And the {people} gonna {action}')
```
How can I change it to repeat the action five times?
4 Answers
You could also use string multiplication in Python to repeat the action:
```python
print(f'And the {people} gonna {action * 5}')
```
But remember, this will concatenate without spaces unless you format it to include spaces.
You can use a for loop to print the action multiple times. Just do something like this:
```python
for i in range(5):
print(action)
```
Definitely need to clarify your question a bit more. Maybe share an example of what you're expecting the output to look like, like:
```
Bob runs.
Mike jumps.
And so on.
```
This could help others understand your requirements better!
If you're looking to format it nicely in your string, you could do:
```python
print(f'And the {people} gonna {' '.join([action] * 5)})
```
This will put spaces between each action!
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String