How to write a function that accepts text as input and returns the number of characters? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write a function that accepts text as input and returns the number of characters?

5th Oct 2021, 12:47 PM
Алексей Иванов
Алексей Иванов - avatar
7 Answers
+ 4
use len(). If not, loop through and count em
5th Oct 2021, 12:48 PM
Slick
Slick - avatar
+ 6
Slick , be careful by using len(), because it returns the total numbers of characters including whitespace.
5th Oct 2021, 7:21 PM
Lothar
Lothar - avatar
+ 4
Slick , you are right! space are also characters.
6th Oct 2021, 2:24 PM
Lothar
Lothar - avatar
+ 3
Алексей Иванов , can you show us your code please? thanks! can you answer this: - what should count? letters digits punctuation
5th Oct 2021, 7:16 PM
Lothar
Lothar - avatar
+ 2
Lothar are spaces not characters? If OP wanted just letters I would've just expected that in the question. Lothar just bustin your chops! you're so right as well haha
5th Oct 2021, 7:23 PM
Slick
Slick - avatar
0
I'm sorry I didn't see Actual?
12th Oct 2021, 2:29 PM
Алексей Иванов
Алексей Иванов - avatar
12th Oct 2021, 2:30 PM
Алексей Иванов
Алексей Иванов - avatar