What if we use .replace() without any argument? What will happen? Like, we can use .split() without any arguments and it works, what is the default argument for .replace()?
You might need a little info about the notation to get started: https://docs.python.org/3/reference/introduction.html#notation (I think this one carries through to the regular documentation too). Otherwise it’s something you’ll get better used to the more you actually use it.
It’s often helpful to run a quick interactive session to test things too, help("".replace) for example should give a quick overview of the method and you can play around with it from there.
I’ve downloaded anaconda but am struggling to use it a little bit - because otherwise I would just ‘play around with it’ as you say. I’ve done a few projects in Jupyter Notebook but that’s different. Spyder seems a bit clustered. What IDE would you recommend from Anaconda?
from re import subn
sentence = "Hello There Everyone"
result = subn("e", "E", sentence)
new_sentence, count = result
print(new_sentence)
# "HEllo ThErE EvEryonE"
print(count)
# 5
this is from the project ‘thread shed’
this is getting a little too complicated for its own good isn’t it?
total_sales = 0
for i in sales:
total_sales += float(i.strip("$"))
thread_sold_split = []
for i in thread_sold:
l = i.split("&")
for j in l:
thread_sold_split.append(j)
if len(thread_sold_split) > 1:
n = 0
while n < len(thread_sold_split) - 1:
m = n + 1
while m < len(thread_sold_split) - 1:
if thread_sold_split[n] == thread_sold_split[m]:
thread_sold_split.pop(n)
m += 1
n += 1