Ask the user for an integer n and given that use a function

Ask the user for an integer n and given that use a function to print \"Hello\" n times consecutively. Eg if n is 3 your output should be \"HelloHelloHello\" #main function 2 def main(): n = int(input()) #your call to printHello function goes here - Your code #printHello function def printHello(n): #your code for the function goes here - Your code main()

Solution

def main():
n = int(input())
printHello(n)
  
def printHello(n):
s = \"\"
for i in range(0, n):
s = s+ \"Hello\"
print s

main()

Output:

sh-4.3$ python main.py   

3                                                                                                                                                                                                                                                      

HelloHelloHello

 Ask the user for an integer n and given that use a function to print \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site