- 1

Returning from functions

Can you guys help me? We are creating our own social network application and need to have a hashtag generator program. Complete the program to output the input text starting with the hashtag (#). Also, if the user entered several words, the program should delete the spaces between them. Sample Input code sleep eat repeat Sample Output #codesleepeatrepeat Hint You can use the replace() function to replace the spaces (" ") with empty strings (""). See how it works:

5th Sep 2021, 11:24 PM
Jonghyun Lee
Jonghyun Lee - avatar
4 Answers
+ 3
1. Get the input and save it into a variable. 2. Make a function that takes the variable as a parameter. Inside the function use the replace() method to remove any spaces from the variable string that was input. Append a octothorp aka hashtag to the beginning of the string and return it from the function. 3. Call the function passing the input variable and print() its returned value. Or don't make a function and just do it all inline.
5th Sep 2021, 11:57 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
s = input() def hashtagGen(text): s1=text.replace(" ","") return "#"+s1 print(hashtagGen(s)) We used + operator to add 2 strings.
11th Feb 2024, 2:15 PM
Monisha D
Monisha D - avatar
0
Check this out; s = input() def hashtagGen(text): # space is replace with no space"" s1 = s.replace(" ","") return (print("#"+s1)) hashtagGen(s)
27th Jan 2023, 3:22 PM
Himasha Nethmini
Himasha Nethmini - avatar