string='I love #Snorlax he is a beast #op#letsgo'
for item in string.split():
if item.startswith('#'):
print(item)
The problem with my code is that the output i get is:
#Snorlax
#op#letsgo
The output should be
#Snorlax
#op
Try this:
string='I love #Snorlax he is a beast #op#letsgo'
for item in string.split():
if item.startswith("#"):
print("#" + item.split("#")[1])
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments