Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

i dont know whats wrong in this logic

how do i multiply strings with integers?

4 Answers

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

It's as simple as:

string = 'Hi ' * 5

The 5 would be replaced by the argument count inside a function

Ken Alger
Ken Alger
Treehouse 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 string_value, integer_value times. For example:

def print_hi(count):
  print("Hi " * count)


Would yield: Hi Hi Hi Hi Hi

Post back if you still have questions.

Happy coding,

Brendan's code passes - the code from the other people who answered does not.