I have texts coming from the database and I try to check text with specific numbers and characters. I need to know how to check a word if the first letter is "1" or not.
How could I do this?
I have texts coming from the database and I try to check text with specific numbers and characters. I need to know how to check a word if the first letter is "1" or not.
How could I do this?
You can access the first letter of the word in the same way as the first item in a list. But remember that the first index is 0
.
if word[0] == "1":
print("First letter is 1")
You can use text.startswith("1")
which will return True or False depending on whether your text starts with '1' or not