How are these different(different outputs)!??!?!??! ( the bottom one is the correct one!
dic={}
for i in words:
if i not in dic:
dic[i]=0
else:
dic[i] += 1
VERSUS
dic={}
for i in words:
if i not in dic:
dic[i]=0
dic[i] += 1
How are these different(different outputs)!??!?!??! ( the bottom one is the correct one!
dic={}
for i in words:
if i not in dic:
dic[i]=0
else:
dic[i] += 1
VERSUS
dic={}
for i in words:
if i not in dic:
dic[i]=0
dic[i] += 1
Hi!
Welcome to the forums
Make sure to format the code in your posts when you ask questions because this makes it more readable and also often affects how your code would work (like in python):
First press the button and then paste the code between the tick marks
Also note if you type python
in your terminal you can test how python works interactively (there’s an online shell for this as well here:Welcome to Python.org)
Thank You for your reply, I will take into account of the things you have mentioned!