Skip to main content

L 5

today i am doing some further work with editing strings.

in this code i reformat a badly written sentence.

start = "        THis is_BadlY wriTt#N_______"
print(start)
print(start.replace("_"," ").replace("#","E").rstrip().lstrip().lower().capitalize() + ".")

in this code i work on printing out only selected pieces of a string.

var = "6 six 7 seven 8"
six = var[0]
print("six is", six + " or", var[2:5] + ", not", var[1::5])

Comments