Python Forum
Convert number to a different base and make calculations
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert number to a different base and make calculations
#11
It has been 30 minutes and i still can not understand why python wont remove (2) from my string
value1="TEST(2)"
value1.replace("(2)","")
print (value1)
it will work on idle but not on the editor.Solving this small issue will make me end my project..I hope
Reply
#12
Strings are immutable, their methods don't change them in place. Instead their methods create a new string. You want value1 = value1.replace('(2)', '').
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#13
Thanks for the reply! Got it working with a minor tweak
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to convert every even number in a list to odd? Bruizeh 4 3,671 Aug-27-2021, 03:04 AM
Last Post: naughtyCat
  Weird problem with reading from file and performing calculations pineapple999 1 2,956 Jul-25-2019, 01:30 AM
Last Post: ichabod801
  Convert string to a specific number of bytes artblinked 1 2,399 Mar-28-2019, 08:43 PM
Last Post: Larz60+
  Prime numbers calculations frequency 3 2,938 Nov-27-2018, 07:07 PM
Last Post: micseydel
  Calendar calculations frequency 10 5,534 Nov-13-2018, 07:34 PM
Last Post: frequency
  dc circuit calculations michaelj 1 2,295 Nov-01-2017, 09:19 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020