Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Counting | String Methods
course content

Contenido del Curso

String Manipulation in Python

CountingCounting

Let's consider some other methods that can be applied to strings. One of them can help us count the number of appearances of some symbol/substring within a string.

To count the number of symbol/substring in string use .count(symbol/substring) method. For example,

Note

This method is case-sensitive to symbols. For the example above, string.count('m') will return 0, while string.count('M') will return 1.

Tarea

You are given string "Introduction to Python". You need to calculate the number of symbols 'o' and 't' in this string.

¿Todo estuvo claro?

Sección 2. Capítulo 1
toggle bottom row
course content

Contenido del Curso

String Manipulation in Python

CountingCounting

Let's consider some other methods that can be applied to strings. One of them can help us count the number of appearances of some symbol/substring within a string.

To count the number of symbol/substring in string use .count(symbol/substring) method. For example,

Note

This method is case-sensitive to symbols. For the example above, string.count('m') will return 0, while string.count('M') will return 1.

Tarea

You are given string "Introduction to Python". You need to calculate the number of symbols 'o' and 't' in this string.

¿Todo estuvo claro?

Sección 2. Capítulo 1
toggle bottom row
some-alt