You can remove the last two digits of a string in python using string slicing. Here is an example code block:
main.py71 chars4 lines
Output:
main.py9 chars2 lines
In the example above, the [:-2]
notation indicates that we're slicing the string from the first character to the second last character. This effectively removes the last two digits from the string. You can replace my_string
with the string variable you want to modify.
gistlibby LogSnag