Reputation: 339
I was practising a python related problem at Hackerrank. I am a total newbie to python. The Problem was to simply write a function, which checks if a year is leap year or not according to the Gregorian calendar.
I looked in the discussions tab, where I found out the answer, I decided to not to copy up the code and instead I wrote the code after understanding it.
So I wrote it this way:
if year%4 == 0 and (year%100 != 0 or year%400 == 0):
leap = true;
When I ran the tests, It ended up with two failed tests and two timed out tests. So I checked the solution in the discussions tab again and changed my code to:
if year%4 == 0 and (year%100 != 0 or year%400 == 0):
leap = True
When I ran this code, all my test cases passed, without any errors.
Does python have only 'True' and not 'true'?
Thank you in advance. :)
Upvotes: 0
Views: 1560
Reputation: 9
Truth and False are keywords meaning true and false . Just like the keyword for null is None . Truth is the literal truth value
Upvotes: 0
Reputation: 1
Python is case sensitive and strongly typed.
'true' is not the same as 'TRUE'
Upvotes: -1
Reputation: 465
The difference is that True
is the keyword and true
is not. The flag is case sensitive. It is always True
and False
, not true
or false
.
Upvotes: 1
Reputation: 2166
True is capitalised because Python built in constants are capitalised: https://docs.python.org/3/library/constants.html
"true" would create an error, as the program will be looking for a non-existant variable called true.
Upvotes: 3