if( $var1 > 50 && $var1 < 100 ){
echo 'hello world';
}
if( $var1 == 3 || $var1 == 7 ){
echo 'hello world';
}And in Python.if var1 > 50 and var1 < 100:
print('hello world')
if var1 == 3 or var1 == 7:
print('hello world')
Making the transition from PHP to Django easier.
if( $var1 > 50 && $var1 < 100 ){
echo 'hello world';
}
if( $var1 == 3 || $var1 == 7 ){
echo 'hello world';
}And in Python.if var1 > 50 and var1 < 100:
print('hello world')
if var1 == 3 or var1 == 7:
print('hello world')
Just a quick note: "and" in Python acts like "&&" in PHP, not like "AND". Same goes for "or": It behaves like "||", not like "OR". That can trip you up if you're going from one to the other.
ReplyDeleteJust a side note about comparisons.
ReplyDeleteIn Python, the following is legal:
if 50 < var1 < 100
This is the same as:
if var1 > 50 and var1 < 100
You might want to rethink using Python 3 specific syntax when Django (which your site is focused on) doesn't even support Python 3 yet and probably won't for quite some time.
ReplyDelete