Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- 5. User enters a text string. You have to remove all “white symbols” and punctuation signs from it before further processing.
- Then, you need to print out each unique symbol and it’s quantity within an input string.
- DO NOT use collections for that.
- Example:
- Enter string: Hello world!
- Result:
- E: 1
- n: 2
- t: 2
- e: 2
- r: 3
- s: 1
- i: 1
- g: 1
- H: 1
- l: 2
- o: 2
- w: 1
- d: 1
- 5.1. Make this program case-insensitive.
- """
- text=input("enter some text:")
- text=text.replace('\t','')
- text=text.replace(' ','')
- text=text.replace(',','')
- text=text.replace('.','')
- text=text.replace(':','')
- text=text.replace(';','')
- print("case sensitive case:")
- counter = [i+65 for i in range(122)]
- for i in counter:
- if chr(i) in text:
- print(chr(i), ":", text.count(chr(i)))
- else:
- pass
- print("case insensitive case:")
- counter = [i+65 for i in range(26)]
- counter2=0
- for i in counter:
- if (chr(i) in text) or (chr(i+32) in text):
- counter2=text.count(chr(i))+text.count(chr(i+32))
- print(chr(i),"or ", chr(i+32),":", counter2)
- else:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement