Hi guys, i just want to ask if how can i count the alphanumeric of a given string. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi guys, i just want to ask if how can i count the alphanumeric of a given string.

14th May 2022, 10:13 AM
trash
3 Answers
+ 5
Prepare the variable for storing number of alphanumeric, and initialize its value by zero. Iterate through the string, check whether .isalnum() method returns true for the i-th character. If <character>.isalnum() returns true, increment the alphanumeric counter variable.
14th May 2022, 10:36 AM
Ipang
+ 2
Ipang Now that I see your answer, I understand the question. 😁👍
14th May 2022, 10:47 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
🤷🏻‍♂️ Are you trying to get the ordinals (numbers) of each letter in a string txt = input() print([ord(i) for i in txt])
14th May 2022, 10:16 AM
Rik Wittkopp
Rik Wittkopp - avatar