Importing modules? | Sololearn: Learn to code for FREE!

0

Importing modules?

Hi, can someone help me, please? I am using the code playground, on python, and was wondering if you could import modules, and functions from those modules into another python file. Can you import things from your own computer (not in sololearn), do you have to export everything in order to import?

3/12/2021 9:25:15 AM

Kamil Hamid

2 Answers

New Answer

+5

You simply create a file, and import anything from it in another file with exporting. It won't work on sololearn !

+4

s = ''' def greeting(name): print(f'Hello {name}, how are you?') ''' with open('mymodule.py','w') as f: f.write(s) import mymodule mymodule.greeting('John')