+ 2

When to put parentheses in if statement and when not?

For example we write if(1==1) but we can also write if 'hello' in list:? Please anyone who can give the best explanation to this?

10th Jul 2019, 5:57 PM
Muhammad Hashim
Muhammad Hashim - avatar
3 Answers
+ 5
In Python, you do not need parentheses in conditionals, though most programming languages do.
10th Jul 2019, 6:28 PM
CeePlusPlus
CeePlusPlus - avatar
+ 2
You described two different languages. In python, you don't need parentheses (same as brackets), but in most languages you do
10th Jul 2019, 6:02 PM
Airree
Airree - avatar
+ 2
Sorry I mean 'parentheses' in Python specially in conditionals
10th Jul 2019, 6:06 PM
Muhammad Hashim
Muhammad Hashim - avatar