Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

sahil jagdale
Courses Plus Student 1,043 Pointsi dont know whats wrong in this logic
how do i multiply strings with integers?
4 Answers

Chris Freeman
Treehouse Moderator 67,989 PointsIt's as simple as:
string = 'Hi ' * 5
The 5 would be replaced by the argument count
inside a function

Ken Alger
Treehouse TeacherSahil;
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 string_value
, integer_value
times. For example:
def print_hi(count):
print("Hi " * count)
print_hi(5)
Would yield: Hi Hi Hi Hi Hi
Post back if you still have questions.
Happy coding,
Ken

Brendan Whiting
Front 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)

james white
78,399 PointsBrendan's code passes - the code from the other people who answered does not.