Given a string consists of repeated characters. Write a function to process the string to return number of repeated characters in a dictionary.
string.count(character)
functionInput:
string = "The more that you read, the more things you will know, the more that you learn, the more places you willl go."
Output:
{'T': 1, 'h': 7, 'e': 11, ' ': 21, 'm': 4, 'o': 10, 'r': 6, 't': 8, 'a': 5, 'y': 4, 'u': 4, 'd': 1, ',': 3, 'i': 3, 'n': 3, 'g': 2, 's': 2, 'w': 3, 'l': 7, 'k': 1, 'p': 1, 'c': 1, '.': 1}
keys = dict.keys()
returns a list of keysGiven a string of random characters. Write a function to sort them in English alphabatical order.
Input:
string = 'dsajlvwjeoijvdskavljwioenvjskdlahj'
Output:
aaadddeehiijjjjjjkklllnoosssvvvvww
Hint
chr()
and ord()
Given string of random letters, digits and symbols. Write a function to return them in different lists.
Input:
import re
string = 'fjsdlkajlv463247836ewiFJKS&*$^&#$JFIEfjdksljVLWEJKjdkfjkd'
Output:
['f', 'j', 's', 'd', 'l', 'k', 'a', 'j', 'l', 'v', 'e', 'w', 'i', 'F', 'J', 'K', 'S', 'J', 'F', 'I', 'E', 'f', 'j', 'd', 'k', 's', 'l', 'j', 'V', 'L', 'W', 'E', 'J', 'K', 'j', 'd', 'k', 'f', 'j', 'k', 'd']
['4', '6', '3', '2', '4', '7', '8', '3', '6']
['&', '*', '$', '^', '&', '#', '$']
Write a function to reverse a given string.
Input:
string = "Children must be raught how to think, not what to think"
Output:
"kniht ot tahw ton ,kniht ot woh thguar eb tsum nerdlihC"
Given a string consists of different words end with ing
. Write a function to append ly
to words end with ing
, and ing
to those are not end with ing
, ignore those already are end with ly
.
endswith()
Input:
string = "He is fully absessed with eating. Eating and eating, don't stop forever!"
Output:
"Heing ising fully absesseding withing eatingly. Eatingly anding eatingly, don'ting stoping forever!ing"
ing
or ly
by splitting the word