Home > Back-end >  How to split a string after two characters? [duplicate]
How to split a string after two characters? [duplicate]

Time:09-21

I have a program which is reading the temperature. It read it and prints it like "1684 °C" and I need to split this to be like "16,84 °C". The number is a string.

CodePudding user response:

You might try to use the following:

my_str = "1684 °C"
my_str = my_str[:2]   ","   my_str[2:]
  • Related