+ 2

Please help having error (showing my work)(other question one next on because it exceeded the word limit )

It says I’m using. ““variable ‘i’ before assignment “” but i assigned it already year = int(input()) a = (year % 4) b = (year % 100) c = (year % 400) a = 'i' i == 0 if a == 0: i += 1 else: print ('Not a leap year') if b == 0: i += 1 else: print ('Not a leap year') if c == 0: i += 1 if a >= 3: print ('Leap year') else: print ('Not a leap year')

22nd Sep 2022, 1:16 AM
Lz1234
5 ответов
+ 1
Also, you don't necessarily need to assign a b and c. You can use embedded if statements. You can write it like so: year = input(int("what year is it?")) if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: print:("it is a leap year") else:("it is not a leap year") else:print("it is a leap year") else:print("not a leap year")
22nd Sep 2022, 3:08 AM
Darkjedi
+ 1
Darkjedi Yes i tried the same way you did with one mostake the second else i made to “not leap year “ but your ways correct
22nd Sep 2022, 8:32 PM
Lz1234
+ 1
Darkjedi When i did as you said it still gave me the same message First: i == 0 Then: a == "i"
22nd Sep 2022, 8:37 PM
Lz1234
+ 1
There are many errors, but the way you posted the question makes it difficult to help. Let's first fix the question: 1. Paste your code in Code Playground 2. Remove the code from the question description 3. Add in the question description a link to your code in Code Playground 4. Explain your difficulties in the question description Then we'll address the syntax and logic issues.
23rd Sep 2022, 12:37 AM
Emerson Prado
Emerson Prado - avatar
0
Yes, you are. Correction should assign i before trying to assign it to a First: i == 0 Then: a == "i"
22nd Sep 2022, 2:58 AM
Darkjedi