create a function that multiple 40 times hello world and add 20 times the holoworld in a string in python

Below is a Python function that generates a string by concatenating "Hello world" 40 times and then adding "Hello world" 20 more times:

main.py
def hello_world_string():
    hello_world = "Hello world"
    hello_world_40_times = hello_world * 40
    hello_world_20_times = hello_world * 20 
    return hello_world_40_times + hello_world_20_times
202 chars
6 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