Python Forum
Convert number to a different base and make calculations - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Convert number to a different base and make calculations (/thread-14581.html)

Pages: 1 2


RE: Convert number to a different base and make calculations - frequency - Dec-13-2018

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


RE: Convert number to a different base and make calculations - ichabod801 - Dec-13-2018

Strings are immutable, their methods don't change them in place. Instead their methods create a new string. You want value1 = value1.replace('(2)', '').


RE: Convert number to a different base and make calculations - frequency - Dec-17-2018

Thanks for the reply! Got it working with a minor tweak