eg: "ABC.sample.int.int01" like that, only want to check this string contains 3 dots. Thanks
Asked
Active
Viewed 2,686 times
-2
-
Do you want to check if it contains *exactly* three dots? Can you tell more about the original problem you're solving? – decorator-factory Apr 14 '22 at 07:46
-
`"ABC.sample.int.int01".count('.')` ... ? – Matthias Apr 14 '22 at 07:49
-
`"ABC.sample.int.int01".count('.') == 3`? – mozway Apr 14 '22 at 07:49
1 Answers
0
You can check it like this, with count
attribute of str
in python. If it is equal to 3, then your strings actually contains exactly 3 dots.
if 'ABC.sample.int.int01'.count('.') == 3:
...
else:
...

Amir reza Riahi
- 1,540
- 2
- 8
- 34