Below is a Python function that generates a string by concatenating "Hello world" 40 times and then adding "Hello world" 20 more times:
main.py202 chars6 lines
In the above code, we first defined a variable hello_world
to hold the "Hello world" string. We then used string multiplication to create another variable hello_world_40_times
that contains "Hello world" repeated 40 times. Similarly, we created another variable hello_world_20_times
that contains "Hello world" repeated 20 times.
Finally, we returned the concatenation of the first string hello_world_40_times
and the second string hello_world_20_times
.
gistlibby LogSnag