Occurence of a multiple symbol in a string-Python

Monty
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
rassar

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

find last occurence of multiple characters in a string in Python

From Dev

First and last occurence of a symbol (python without regex)

From Dev

Python extract occurence of a string with regex

From Dev

Counting occurence within a string Python

From Dev

php find multiple occurence of string in string

From Dev

Find last occurence of string in multiple files

From Dev

Python Regular expression: is there a symbol to search for more than one occurence of a pattern?

From Dev

Python Regular expression: is there a symbol to search for more than one occurence of a pattern?

From Dev

Removing all the keys with multiple occurence of values in Python

From Dev

Search & Replace multiple occurence of pattern in a string after enclosing it between [ and ]

From Dev

Finding last occurence of string

From Dev

Finding last occurence of string

From Dev

Count occurence of string in Arraylist

From Dev

Check vowels occurence in a string

From Dev

Python string cent symbol conversion

From Dev

Python - replacing string/symbol with numbers

From Dev

python dataframe count occurence

From Dev

Inserting XML Data in multiple occurence

From Dev

Inserting XML Data in multiple occurence

From Dev

Multiple line, repeated occurence matching

From Dev

regex multiple occurence of phrases java

From Dev

RegEx to match last occurence of a string

From Dev

Count Repeated occurence of a substring in string

From Dev

How to check for occurence of name in string?

From Dev

Targeting a specific occurence in a string and replacing it

From Dev

Check if string contains occurence of digit

From Dev

Count Repeated occurence of a substring in string

From Dev

How to check for occurence of name in string?

From Dev

Unable to replace String occurence in java?

Related Related

  1. 1

    find last occurence of multiple characters in a string in Python

  2. 2

    First and last occurence of a symbol (python without regex)

  3. 3

    Python extract occurence of a string with regex

  4. 4

    Counting occurence within a string Python

  5. 5

    php find multiple occurence of string in string

  6. 6

    Find last occurence of string in multiple files

  7. 7

    Python Regular expression: is there a symbol to search for more than one occurence of a pattern?

  8. 8

    Python Regular expression: is there a symbol to search for more than one occurence of a pattern?

  9. 9

    Removing all the keys with multiple occurence of values in Python

  10. 10

    Search & Replace multiple occurence of pattern in a string after enclosing it between [ and ]

  11. 11

    Finding last occurence of string

  12. 12

    Finding last occurence of string

  13. 13

    Count occurence of string in Arraylist

  14. 14

    Check vowels occurence in a string

  15. 15

    Python string cent symbol conversion

  16. 16

    Python - replacing string/symbol with numbers

  17. 17

    python dataframe count occurence

  18. 18

    Inserting XML Data in multiple occurence

  19. 19

    Inserting XML Data in multiple occurence

  20. 20

    Multiple line, repeated occurence matching

  21. 21

    regex multiple occurence of phrases java

  22. 22

    RegEx to match last occurence of a string

  23. 23

    Count Repeated occurence of a substring in string

  24. 24

    How to check for occurence of name in string?

  25. 25

    Targeting a specific occurence in a string and replacing it

  26. 26

    Check if string contains occurence of digit

  27. 27

    Count Repeated occurence of a substring in string

  28. 28

    How to check for occurence of name in string?

  29. 29

    Unable to replace String occurence in java?

HotTag

Archive