Python Python Basics (2015) Logic in Python Print "hi"

Dolapo Sekoni
PRO
Dolapo Sekoni
Pro Student 1,431 Points

help with task

kindly assist with printer.py

printer.py
def printer(count):
count * 3
   print("Hi")

3 Answers

Dave StSomeWhere
Dave StSomeWhere
19,732 Points

You should probably review the video again, it appears you're missing some key concepts.

The challenge asks you to: Write a function named printer. The function should take a single argument, count, and should print "Hi " as many times as the count argument. Remember, you can multiply a string by an integer.

  1. Write a function name printer - your function is not coded correctly and your first statement in the function is both wrong/unnecessary and not indented.

  2. The function should take a single argument - your function does not take any arguments - double check the video on how functions take arguments

  3. You should print "Hi" as many times as the count argument - this should be part of your print statement

Ask again if still confused after reviewing the vid again, don't think it would help much to just write the code for you and take all the fun out of it :smile:

Dolapo Sekoni
PRO
Dolapo Sekoni
Pro Student 1,431 Points

thanks Dave,

i reviewed the video again and came up with this. but it still didn't work. from my understanding, the function name is printer and the argument count is in parenthesis. kindly assist

def printer(count): print("Hi " * {}.format(count))

printer(4)

Dave StSomeWhere
Dave StSomeWhere
19,732 Points

OK Dolapo,

Good that you picked up how to specify the argument. Now, their hint that you can multiply the string "Hi" by count will print "HiHiHi" - you don't need or want the format method for this challenge - it is simpler than you're thinking.

Here's what works - hopefully it makes sense - just getting a function to accept an argument and using multiply with a string:

def printer(count):
    print("Hi" * count)
Dolapo Sekoni
PRO
Dolapo Sekoni
Pro Student 1,431 Points

thanks Dave..... guess i need to think more as a programmer... couldn't believe this is what gave me sleepless night. did it and it works...........

thanks for your time bro