Say i have a string called cool and cool is set to "cool°"
cool = "cool°"
how do i remove the degree symbol from the string?
Since strings are immutable, use the replace function to reassign cool
cool = "cool°"
cool = cool.replace("°","")
cool
'cool'
If they are at the end of the string use str.rstrip
:
cool = "cool°"
cool = cool.rstrip("°")
print(cool)
cool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With