Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Variable Assignment

Give Feedback

Think of a variable as a name attached to a particular object. In Python, variables need not be declared or defined in advance, as is the case in many other programming languages. To create a variable, you just assign it a value and then start using it. Assignment is done with a single equals sign (=).

iamscottdavis on Dec. 10, 2019

I installed ipython on my chromebook but it won’t run.

Martin Breuss RP Team on Dec. 10, 2019

You might have to close and re-open your terminal @iamscottdavis

Geir Arne Hjelle RP Team on Dec. 10, 2019

I’ve recently had some weird issues with prompt_toolkit, one of the dependencies of IPython. Maybe that’s what you’re running into?

I got a cryptic error message like TypeError: __init__() got an unexpected keyword argument 'inputhook'. If this is your problem as well, the best solution should be to update to IPython >= 7.10 which should have fixed this. Another workaround is to downgrade prompt_toolkit to version 2.

See some discussion on github.com/ipython/ipython/issues/11975

If you are having other problems, feel free to post your error messages :)

kiran on July 18, 2020

if i declare the variable in any one loop in python.

while True:
    a = 2
print(a) #2

now my question is a is local/global variable? in C it is local variable but what about python? in Python even i declare a variable with in the loop it become a global variable?

Martin Breuss RP Team on July 18, 2020

In Python, it will keep the last value it got assigned within the loop also outside in the global scope. That is why a is still accessible and has a value in your example, also outside of the loop’s scope.

Become a Member to join the conversation.