How to write a program in pthon to ask the user to input a string and display how many characters are numeric and alphabet | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to write a program in pthon to ask the user to input a string and display how many characters are numeric and alphabet

pls help me to pass thes exam

12th Jan 2018, 10:27 AM
Jun Alcain
Jun Alcain - avatar
4 Answers
+ 21
str=input('Pls input string: ') print(len(str))
12th Jan 2018, 11:08 AM
Nithiwat
Nithiwat - avatar
+ 2
It’s possible he was looking for something like this: https://code.sololearn.com/clr23B1SHBce/?ref=app
15th Jan 2018, 2:27 PM
Talley Berry
Talley Berry - avatar
+ 2
inp = input("\n") print(inp) alpha = 0 num = 0 for c in inp: if '0' <= c <= '9': num += 1 elif 'a' <= c <= 'z' or 'A' <= c <= 'Z': alpha += 1 print('alpha: {}\nnum: {}'.format(alpha,num))
17th Jan 2018, 8:46 AM
Jun Alcain
Jun Alcain - avatar
- 1
str = row _ input ("Enter a str:") print (Len(str))
4th Mar 2018, 2:52 PM
Ahmed Shwrov
Ahmed Shwrov - avatar