+ 1

Why not working? please help

local variable reference before assignment https://code.sololearn.com/cYWy4hx6i2li/?ref=app

9th Jan 2021, 1:35 PM
ABHISHEK
ABHISHEK - avatar
17 ответов
+ 9
Abhishek Mazumder , normally variables do need to be declared or initialized. But in your case you are using somethin like this: x*=n-(r-(r-i)) so this means the same as: x = x * n-(r-(r-i)). this will assign the right side expression to x. When x is not declared, this creates an error, because x is also in the expression on the right side.
9th Jan 2021, 1:46 PM
Lothar
Lothar - avatar
+ 2
Means that you reffer to the x variable before it is assigned In your case it is never assigned
9th Jan 2021, 1:39 PM
Qwerty Uiop
Qwerty Uiop - avatar
+ 2
Abhishek Mazumder variables in python are assighned just by giving them a value.
9th Jan 2021, 1:46 PM
Qwerty Uiop
Qwerty Uiop - avatar
9th Jan 2021, 1:46 PM
ABHISHEK
ABHISHEK - avatar
+ 1
Lothar Ooooo😅
9th Jan 2021, 1:48 PM
ABHISHEK
ABHISHEK - avatar
+ 1
Abhishek Mazumder, x=x*(n-(r-(r-i) Can only be done if x already has a value While asigning a variable you cant use its own name in its value
9th Jan 2021, 1:51 PM
Qwerty Uiop
Qwerty Uiop - avatar
+ 1
Should add an variable x=1 And then X=n-(r(r-i))
9th Jan 2021, 4:37 PM
Fahd Labba
Fahd Labba - avatar
+ 1
Телефон
10th Jan 2021, 6:35 PM
Нина
+ 1
Укаво заняття
10th Jan 2021, 6:35 PM
Нина
+ 1
Телефон мобільний зв'язок
10th Jan 2021, 7:16 PM
Нина
0
Qwerty Uiop We have to asign variable in python?
9th Jan 2021, 1:42 PM
ABHISHEK
ABHISHEK - avatar
0
Qwerty Uiop How to fix it?
9th Jan 2021, 1:43 PM
ABHISHEK
ABHISHEK - avatar
0
Ooook
9th Jan 2021, 1:44 PM
ABHISHEK
ABHISHEK - avatar
0
x=x*(n-(r-(r-i) and x has no value
9th Jan 2021, 1:48 PM
ABHISHEK
ABHISHEK - avatar
0
Hi
11th Jan 2021, 8:33 AM
Jacklyn Quansah
0
How are you
11th Jan 2021, 8:33 AM
Jacklyn Quansah