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

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


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
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers


108k users

Browse Categories