+ 5

What does a>b means here?

a=[7,3,9,5] b=[8,0,4] If a>b: print(len(a)) else: print(len(b)) Answer is 3

20th Apr 2019, 3:32 AM
Edwin
Edwin - avatar
6 Respostas
+ 7
First of all, it should be "if" i.e. in lowercase If is a conditional statement It compares a and b But since a and b are lists, it compares first elements of both a and b If the first elements are equal, it will compare the next elements. So, here, 7>8 which evaluates with False So it executes the else part. And it prints the length of b which is 3... What do you actually want to do with the lists?
20th Apr 2019, 3:58 AM
Kartik
Kartik - avatar
+ 7
Interesting Question, i made a code for this one.. and elaborated in code. https://code.sololearn.com/cfwn0t2z5NOx/?ref=app Extending to the answer provided by Kartik Krishnan.
20th Apr 2019, 4:04 AM
Aaditya Deshpande
Aaditya Deshpande - avatar
+ 4
Thanks it's a challenge question in Python I was not able to understand it Typing mistake if
20th Apr 2019, 4:01 AM
Edwin
Edwin - avatar
0
سلام
26th Apr 2019, 10:14 AM
ستایش سودا
ستایش سودا - avatar
- 1
It refers to the length of the list....
20th Apr 2019, 6:14 AM
Sanjay Kamath
Sanjay Kamath - avatar
- 2
> = bigger than Example: a = 5 b = 1 If a>b returns true
20th Apr 2019, 3:58 AM
Lexfuturorum
Lexfuturorum - avatar