+ 1

Why no output on this code?

a = 1 while a >1 and a<10: print(a) a +=1 Why I can't get any output? I'll get output just if on second line I'll change a>=1.

12th Apr 2020, 11:44 AM
Sigitas S
Sigitas S - avatar
10 ответов
+ 6
because a is not greater than 1
12th Apr 2020, 11:55 AM
durian
durian - avatar
+ 4
Because as your using "and" both conditions should be satisfied.And the first condition is failed because "a" should be a>=1.
14th Apr 2020, 4:18 AM
Abhishek
Abhishek - avatar
+ 3
1 is equal to 1 but it's not greater than 1
13th Apr 2020, 6:00 AM
Vijay(v-star🌟)
Vijay(v-star🌟) - avatar
+ 2
Python uses indentation (white space at the beginning of a line) to delimit blocks of code. And a > 1 rerurns false. You can change a or change the condition. a = 1 while a >= 1 and a < 10: print(a) a += 1
12th Apr 2020, 11:58 AM
Denise Roßberg
Denise Roßberg - avatar
+ 2
maklaudas to ping someone: @Username :)
12th Apr 2020, 1:09 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Since a=1, it won't meet the condition of a>1, therefore bringing no output. But if you changed the value for a(a=2)or edited the condition/argument(a>=1), there will be 9 outputs until it stops. A little advice from a learner.
14th Apr 2020, 3:39 AM
Aaron Luke Olvida🇵🇭
Aaron Luke Olvida🇵🇭 - avatar
+ 1
OK. I tried another integer and probably understood how counts: a=1 while a>0 and a <10: print(a) a +=1 Thank you Lily Mea and Mirielle 😉
12th Apr 2020, 12:56 PM
Sigitas S
Sigitas S - avatar
+ 1
12th Apr 2020, 1:11 PM
Sigitas S
Sigitas S - avatar
0
Yes, I know about indentation just mistaken here to write correct 😁 but my question, why not execute a>1 and starts work when I change to a >=1?
12th Apr 2020, 12:14 PM
Sigitas S
Sigitas S - avatar