Hashtag Generator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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))

13th Sep 2021, 5:20 PM
Trevor Rickard
Trevor Rickard - avatar
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(" ", "")
13th Sep 2021, 5:25 PM
A͢J
A͢J - avatar
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 !
26th Nov 2021, 10:08 PM
Keremcan
Keremcan - avatar
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))
28th Jan 2024, 8:00 PM
Ashkan Heravi
Ashkan Heravi - avatar