0
Hashtag Generator
Spoilers!!! contains answer!!! hey guys, so I was playing around with the code for this and somehow got in right but could you explain to me how it's right? I understand the replace function part, but why am I printing hash_tag(s) and not hash_tag(text), and also why is there a return and a print.... s = input() def hashtagGen(text): #your code goes here s1 = s.replace(" ", "") return("#"+s1) print(hashtagGen(s))
3 Answers
0
Trevor Rickard
If you have used s in function directly then what is the use of text?
And indentation is wrong.
Do this:
def hashtagGen(text):
return ("#" + text.replace(" ", "")
0
s = input()
def hashtagGen(text):
snew = text.replace(" ", "") #First you should delete all the space with this action
a = "#" + snew #Then you should be inserting hashtag in the beginning (I know it could be done more efficiently but felt lazy or sth idk ^^)
return a #and ofc you need to return to the first input
print(hashtagGen(s)) #Lastly you need to return and enjoy your project that is working smoothly !
0
#taking a word as input
word = input()
def hashtag(word):
#complete the function body
word = "#" + word
return word
#display the result
print(hashtag(word))