+ 1

Why the below code prints "fatcat" and what bool is doing ?both variables have same length of characters why cat1 is greater ?

cat_1 = "CatF" cat_2 = "CatD" bool = cat_1>cat_2 if bool == True: print("fatcat") else: print ("deadcat")

7th Feb 2019, 3:31 PM
Vishal Gaikwad
Vishal Gaikwad - avatar
7 odpowiedzi
+ 1
Guess that's the fault of that challenge. ;)
7th Feb 2019, 4:21 PM
HonFu
HonFu - avatar
+ 6
Because: ord('F') > ord('D') ☺️🤔🤕
7th Feb 2019, 5:05 PM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar
+ 4
Also, never use bool, int, str etc. as variable names 😤
7th Feb 2019, 4:15 PM
Anna
Anna - avatar
+ 3
It goes by the order of the letters in the alphabet (simply put). Every pair of letters is compared until one higher is found, and f is higher than d. For knowing more about the order of letters, check out the ASCII and unicode tables.
7th Feb 2019, 3:41 PM
HonFu
HonFu - avatar
+ 1
Vishal Gaikwad, sorry, I haven't looked into pygame at all yet!
11th Feb 2019, 12:38 PM
HonFu
HonFu - avatar
0
HonFu how can I contact you?? I have some error in my program(pygame example) and I don't know what's wrong with the code I have spent 2 days to Debug I don't what to do
11th Feb 2019, 12:23 PM
Vishal Gaikwad
Vishal Gaikwad - avatar
0
HonFu Ok But do you know anything about this error AttributeError : 'builtin_function_or_method' object has no attribute 'bottom'
11th Feb 2019, 1:09 PM
Vishal Gaikwad
Vishal Gaikwad - avatar