-2

eg: "ABC.sample.int.int01" like that, only want to check this string contains 3 dots. Thanks

jenny
  • 41
  • 1
  • 5

1 Answers1

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