Dictionary comprehension with if else : Python tutorial 138

preview_player
Показать описание
Guys please help this channel to reach 20,000 subscribers. I'll keep uploading quality content for you.

Python is easy programming language to learn and anyone can learn it, and these tutorials are 100% free in hindi.

You can share this playlist with your brother, sisters and friends. This will surely add some values to their life.

If you follow this complete playlist of python tutorial surely you will learn everything about python programming language.

This video is all about 'Dictionary comprehension with if else statement'

Рекомендации по теме
Комментарии
Автор

Thanks for the free python course. I like your teaching style. you explain clearly. Really, you are a very good teacher.

mikku
Автор

# d={1:'odd', 2:'even'}
dic={}
for i in range(1, 5):
if i%2==0:
dic[i]='even'
else:
dic[i]='odd'
print(dic)
#DIC COMPREHENSION
didto={i:'even' if (i%2==0) else 'odd' for i in range(1, 5)}
print(didto)

arunavasamanta
Автор

You are a good teacher
Thanks for these

shubhamrai
Автор

can we write any condition in key ?
i wrote then it just print the last two numbers in same code that same condition in key and value just i

varuntanwani
Автор

How to use if elif else in dictionary, list comprehension

rachitmittal
Автор

Sir नमस्कार। सर मैंने अपने Android phone (itel mobile) पर एक ऐप इंस्टाॕल किया है "Qpython" but उसमें आपके द्वारा बताई गई यह स्टेटमेंट नहीं execute हो रही है---
sqs={f"Square of {num} is:" num**2 for num in range(1, 11)}
It is giving the err--
"Invalid syntax"
और यह एरर ज्यादातर is: की जगह point out कर रहा है। मैंने ऐप बदल कर फिर से कोशिश की लेकिन फिर वही एरर बार-बार occur हो रही है। कृपया मदद करें या कोई भी जानकार व्यक्ति। धन्यवाद।

hardcode