List String Exercises
Contents
List String Exercises#
Emoji Translator#
Starting with a sentence like:
"oh hai :smile:"
Split it into a list of words
Replace the matching emoji code (
:smile:
) with its symbol (😄).Join it back to a string and print the result.
Bonus: Pick any three (no more than three) from here: https://gist.github.com/rxaviers/7360908
OUTPUT
oh hai 😄
leet converter#
Start with a string like
"hello"
Convert it into a list of individual characters
Replace the following characters:
- a : @
- s : $
- l : 1
- i : !
- e : 3
- o : 0
- t : 7
- space : _
Join it back to a string and print the result.
OUTPUT
h3110
Randomly Swap Character Case#
Convert a string into a list of individual characters
Iterate over the list and randomly either switch the case of the character or leave it the way it is.
Hints:String case functions
str.islower()
,str.isupper()
,str.upper()
andstr.lower()
Change list values with
varname[<index-number>] = <newval>
Join the list back into a new string.
Print the original string and the case-swapped string.
OUTPUT
number: nUmBeR