Welcome to the Treehouse Community
Looking to learn something new?
i dont know whats wrong in this logic
how do i multiply strings with integers?
Chris FreemanTreehouse Moderator 67,989 Points
It's as simple as:
string = 'Hi ' * 5
The 5 would be replaced by the argument
count inside a function
Ken AlgerTreehouse Teacher
First, let me say "Welcome to Treehouse!"
Typically when you want to ask a code related question in the forum it helps if you post the code you are using, even if it doesn't work, so that others can see how you are attempting to solve the issue.
To your question though, in Python you can multiply strings and integers by doing
string_value * integer_value and that will return the
integer_value times. For example:
def print_hi(count): print("Hi " * count) print_hi(5)
Hi Hi Hi Hi Hi
Post back if you still have questions.
Brendan WhitingFront End Web Development Techdegree Graduate 84,696 Points
"Hi"*4 would be "HiHiHiHi". That's what they mean by multiplying a string.
def printer(count): print("Hi"*count)
Brendan's code passes - the code from the other people who answered does not.