Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in Python by (47.6k points)

Is it possible to declare a variable in Python, like so?:

var

so that it initialized to None? It seems like Python allows this, but as soon as you access it, it crashes. Is this possible? If not, why?

1 Answer

0 votes
by (106k points)
edited by

As we know Python is dynamic, so you here you do not need to declare things because they exist automatically in the first scope where they're assigned. So, all you need to do is use a regular old assignment statement as above.

To know more about this you can have a look at the following video:-

Related questions

0 votes
1 answer
0 votes
1 answer
asked Sep 20, 2019 in Python by Sammy (47.6k points)
+1 vote
1 answer

Browse Categories

...