0

I am trying to create a function that takes an integer (n) and returns a string with n-amount of hashes.

Ex:

if n is 5, the string would be : #####

if n is 2 the string would be : ##

2
  • What is the issue then? Commented Sep 10, 2014 at 15:54
  • This function would be quite simple. But what is the problem you're having trying to create such a function? Commented Sep 10, 2014 at 16:00

1 Answer 1

2

Here's such a function:

def f(n):
    return '#' * n

Usage:

>>> f(5)
'#####'
>>> f(2)
'##'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.