+ 4
Program to convert all alphabets,digits and special symbols
Program must be of python..!!
13 Antworten
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 )
+ 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
+ 3
I know the code for alphabets and digits..like by using...is.upper...is.digit...but for special char..i am having problem
+ 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.
+ 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 ..??
+ 3
Sorry for wrong question 🤦♀️🙇♀️🙇♀️
+ 3
Okay. Thanks a lot 😀
+ 2
ok -can you give us one or two samples of what you have to read, check and convert?
+ 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
#...
0
lets see your attempt first.
if you're looking for a hint or tip just say it
0
you can test them with string.punctuation
https://www.geeksforgeeks.org/string-punctuation-in-JUMP_LINK__&&__python__&&__JUMP_LINK/
0
You can change 'whatever' to a user input
0
No problem :)