We use Python 3.6

go back Level: Beginner (img: BG / score: 2) level Bite 115. Count leading spaces

32 out of 32 users completed this Bite ...
Will you be Pythonista #33 to crack this Bite?
Average Bite difficulty 1-10 rating: 1.0
» You can do it! 😌

A small but interesting Bite: given a string with leading indent spacing, calculate the amount of space characters:

  • 'string  ' -> 0 (we only care about leading spacing)
  • '  string' -> 2
  • '    string' -> 4
  • etc...

This can be done in many ways so once done we encourage you to go into the Bite forum (Discussion tab that appears upon solving the Bite) to discuss your solution with fellow Pythonistas ... Have fun!

Github login button