[Tutor] String-manipulation question
Alan Gilfoy
agilfoy at frontiernet.net
Mon Mar 12 03:04:45 CET 2007
#start of triple-letter processing block
if len(roman_input) > 2 and roman_input[0] + roman_input[1] +
roman_input[2] == "MMM":
digital_result += 3000
roman_input = #something to remove those "M"'s from the string
continue
--
My question here boils down to, "Is there a way to remove certain
characters from a string?"
Here, I'm trying to set the variable roman_input (the string's name)
equal to the string minus those characters, the 3 Ms. (being the first
three characters of the string, they would be roman_input[0],
roman_input[1], and roman_input[2].)
Setting the (new) string equal to the (old) string minus those three
characters will enable calculations on the string to keep running,
because I have this piece of code, and similar pieces nested in a loop.
More information about the Tutor
mailing list