+ 4

Program to convert all alphabets,digits and special symbols

Program must be of python..!!

2nd Oct 2019, 1:03 PM
Sparshika
Sparshika - avatar
13 Answers
0
V Sparshika it is as Simple as that: Alpha = [chr(i) for i in range(65, 123) if chr(i).isalpha()] whatever = "HeY What2up ma€£¥¥₩n I am a $tring" upper = 0 lower = 0 digit = 0 special = 0 blancspace = 0 for i in whatever: if i == " ": blancspace += 1 if i not in Alpha and not i.isdigit() and i != " ": special += 1 if i.isdigit(): digit += 1 if i.islower(): lower += 1 if i.isupper(): upper += 1 print("number of digits:", digit) print("number of uppercases:", upper) print("number of lowercases:", lower) print("number of blancspaces:", blancspace) print("number of specials:",special )
4th Oct 2019, 12:22 AM
William M
William M - avatar
+ 4
yes Lothar I have to detect if a character is any of those...and like ...if it is..alphabet given in string...need to convert it to digit ...and so with special characters
3rd Oct 2019, 9:29 AM
Sparshika
Sparshika - avatar
+ 3
I know the code for alphabets and digits..like by using...is.upper...is.digit...but for special char..i am having problem
2nd Oct 2019, 1:25 PM
Sparshika
Sparshika - avatar
+ 3
I have understand that you are talking about characters / letters / digits and special characters. What's not clear is what do you mean by *convert* ? Do you have to detect if a character is letter / digit / special character? Or if it's upper / lowercase? It would be great if you can give us a more precise description.
2nd Oct 2019, 7:19 PM
Lothar
Lothar - avatar
+ 3
Ohh sorry...I wrote wrong question...it's actually.."Count all digits upper case lower case and special characters in a given string" Please can you give any hint of this program ..??
3rd Oct 2019, 5:19 PM
Sparshika
Sparshika - avatar
+ 3
Sorry for wrong question 🤦‍♀️🙇‍♀️🙇‍♀️
3rd Oct 2019, 5:20 PM
Sparshika
Sparshika - avatar
+ 3
Okay. Thanks a lot 😀
4th Oct 2019, 8:56 AM
Sparshika
Sparshika - avatar
+ 2
ok -can you give us one or two samples of what you have to read, check and convert?
3rd Oct 2019, 12:44 PM
Lothar
Lothar - avatar
+ 1
No problem. You can do this counting of upper / lower case in different ways, depending on your experience in python. What you need e.g. is a loop (while or for loop) in which you check each character if it's upper / lower / special character. Here is a code snipped for you to start with. Please try yourself as far as you can go, use google if you stuck or come back to your post and ask. inp = "Learning Python 3 with SoloLearn's app no. 1" upp_ = 0 # ... #check for upper case: for chr_ in inp: if chr_.isupper(): upp_ += 1 #...
3rd Oct 2019, 7:36 PM
Lothar
Lothar - avatar
0
lets see your attempt first. if you're looking for a hint or tip just say it
2nd Oct 2019, 1:23 PM
Taste
Taste - avatar
2nd Oct 2019, 1:33 PM
Taste
Taste - avatar
0
You can change 'whatever' to a user input
4th Oct 2019, 12:22 AM
William M
William M - avatar
0
No problem :)
4th Oct 2019, 9:32 AM
William M
William M - avatar