Home > Blockchain >  Do you need to leave import lines in?
Do you need to leave import lines in?

Time:10-28

Do you need to leave import lines in? For example:

If I do

from random import randrange
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

I'm very new to python and when I take that line out my code does not work. Im not sure if there is a work around to that or if it need to stay. Thanks!

CodePudding user response:

If you use randrange function somewhere in your code - you must have that import statement as it brings this function to your code namespace so you are able to call it.

CodePudding user response:

If you want to use the built in module, you have to import it. Importing it simply allows you to use the classes and functions of the "random" module. Without importing them, there's no function imported and it'll give you error.

  • Related