The best way to learn new things is to take a practical approach
of the things you want to learn. Here is a fragment of code that demonstrates the use of If statement in Python:
Æ’ python command
#1
groceries = {'Quinoa' , 'Kale' ,
'Eggs' , 'Nuts', 'Vodka'}
print(groceries)
#2
if 'Milk' in groceries:
print('yes')
else: print('no milk at all')
#3
if 'Eggs' in groceries:
print('yes')
else: print('no at all')
√ output
{'Nuts', 'Quinoa', 'Vodka', 'Eggs',
'Kale'}
no milk at all
yes
Sign up here with your email
ConversionConversion EmoticonEmoticon