6 Comments
User's avatar
Kuldeep sharma's avatar

import csv

fieldname=['Language1','Language2']

with open(r"C:\Users\kulde\Downloads\example1.csv",'a',newline='') as file :

writer=csv.DictWriter(file,fieldnames=fieldname,)

writer.writeheader()

while True:

org_word=input("Enter a word in languahe 1(or type 'done' to finish):")

if org_word.lower() == 'done':

break

else:

trans=input('enter the translation of {} in the language2 :'.format(org_word))

writer.writerow({'Language1':org_word,

'Language2':trans})

print('{}(language1) has been added with the translation : {} (language2)'.format(org_word,trans) )

Expand full comment
Pratik Dave's avatar

This was good one!! Enjoyed the learning..thanks

Expand full comment
Ardit Sulce's avatar

Glad you liked it!

Expand full comment
Pratik Dave's avatar

What is the best way to read large dict in vscode? I know u showed to look at debugger in pycharm after response.json step when we call api. Is there an easier way to visualize large dict e.g dict of dict?

Expand full comment
Ardit Sulce's avatar

You can use right-click over the code and go to "Run in Interactive Window". That will run the code in an embedded jupyter notebook and you will be able to see the dictionary there.

Expand full comment
Pratik Dave's avatar

Ok, I will check today. Thanks

Expand full comment