find all symbols before . in string in python

To find all symbols before a period (.) in a string in Python, you can use the split method to split the string at the period, and then use indexing or slicing to get the first part of the split string.

Here's an example code snippet:

main.py
my_string = "example.com"
result = my_string.split('.')[0]
print(result) # prints "example"
92 chars
4 lines

In this code snippet, we first define a string my_string that contains a period. We then use the split method with a period as the separator to split the string into two parts. Since we only want the part before the period, we use indexing to get the first part (which has an index of 0) and assign it to the result variable.

Finally, we print the result, which contains all the symbols before the period in the original string.

gistlibby LogSnag