The level of polish of the channel in general is really appreciated , thanks for sharing your knowledge !
The 'key' to learn dictionary comprehension is to practice this 'value'able exercises in this video.
Many thanks for the great content. This should be archived for future data analysts and pythonistas.
Amo a esta mujer! Enseña muy bien!
I'm using this to teach a student about dictionaries, thank you!
First time it was overwhelming for me, but second time it was fun and I could understand it 100%. I need to implement this in real project before I forget it, Thanks a lot.
This might be the best python tutorial I've ever found online. Thanks for sharing.
Excellent material and excellent educational exposition! Very well done!
love your channel. Thank you for simplifying such valuable knowledge! Your delivery is on point.
You are such a skilled teacher! Thank you
This was a really good tutorial showing more uses for comprehensions. Thanks!
Also, the addition of the slides showing the important notes was a really good add. That was very welcome.
Thanks again!
Thank you so much for the incredible feedback, Patricio! Super happy you enjoyed this tutorial! 😃😃😃
Love the examples. Awesome content!
"Let's say that Spiderman is not exactly welcome in this DC dictionary" haha that was funny. I loved the examples.
Great teaching! Thank you!
I needed this video! Thank you stay awesome!
Love the examples, thank you
Great video, it is too clear.
A little variation of your code for the exercise #3:
users = ["mariyasha888", "KnotABot", "SpongiBOBO", "IAMBATMAN"]
keys = {
"id": lambda id: id,
"username": lambda username: users[username],
"password": lambda passw: "".join(random.choices(string.printable, k=8))
}
data = [{key:(val(i)) for (key,val) in keys.items()} for i in range(len(users))]
Maybe it's not the best way to do it, but it's just for practice 🙃. I'm learning python 😅. and your videos are very useful!!!
A million thanks Maria, your explanation is very good
your explanation is very clear, thank you!
Thank you so much!!!!
Amazing! was looking forward to this video!! thank you thank you!!
Best tutorial ever
Very Useful Thanks!
Just helped me tackle my dictionary mental block.. Good stuff!
This is great. Thanks.
Excellent work! The clarity and didactics with which you have explained each concept are impressive. You have managed to break down complex topics into simple and accessible explanations, which is essential for deep understanding. Your ability to maintain simplicity without losing the essence of the concepts is truly admirable. Keep it up! Congratulations..
Thanks 😊
Mariya, you can turn the password generator into a function call. And I also added a UID function as well. Great tutorial though. Thanks so much!
Excellent.
Very well explained! I like your videos. They help me better understand the Python language. Keep up the good work. 👍🙏
Thanks
Awesome video, I've learnt a lot!! Thank you so much
Thank you Mariya. I found this very helpful and easy to understand.
Thanks. Great video! I haven’t used dictionaries much yet, but I’ll come back to this when I do.
This was an awesome tutorial 👍👍👍
The most complete tutorial on DC. Can you please sware more on that
Indeed your best! ♥
Thanks a lot ! ❤❤. I was learned something from you. You are also better than my python profesor . U r taught something to me recent days . U r way speech and teaching is amazing itz easy to understand (but some topics are tough ) although u r videos are great 🥰
As always the examples you choose are always related to my use cases.
Thanks a lot for the supper intuitive video.
That's awesome!!! Super happy I could telepathically guess the most useful examples! 😁😁😁
Great tutorial I like very much. Thank you Mariya
Mariya, Thank You for your very informative and energetic videos. Your videos are excellent and flow so well. Keep up the great work.
Wow, thanks dear
Very useful ! 🏆🏆🏆🏅🏅🏅Thank you very much !!! 🙏🤗
amazing tips, thx for sharing !
Thank you for this really good video. Definetly the last example was "WOW. I wouldnt be able to do it". Nice !!!!
Thank you^^ This is very helpful.
Maria, thanks for the lessons. Almost everything is clear and without translation. zip is faster
Tank you very much for the video . YOur explanations are awesome
It’s really awesome thank you for the video
Realy good video thanks a lot !
I feel like dictionary comprehensions lose a little bit of its readability compared to a conventional loop once you start applying multiple conditions. Especially with group else statements rather than the traditional elif which (as you mentioned) doesn't exists within the comprehension.
But really nice to know about the feature as it never occurred to me that this existed.
I absolutely agree! I find that Comprehensions are much more comprehendible with lists hahahaha when it comes to dictionaries - the syntax becomes un-Pythonic very fast 😅
With that said, I use it way more often than traditional loops. I think I trained my brain to actually find it intuitive 🙃 hahahaha
@@PythonSimplified even if it looks less redable, i so much enjoy using a comprehenssion of everything, agree with you [x:=str(i)+str(i)[-1] for i in range(0,20,10)][1]+'%' 🙂
lists/dicts comprehension are constantly on that line where they are either great and easy to make and read or just long and ugly and make it harder to read so sometimes they are great, but sometimes it´s just better to do normal for loops
You are a great teacher. Smart and beautiful
Thanks a lot! This content is very important for advanced python learn. 😃
Great!
I just discovered your channel and I've enjoyed following along with you. You are a great teacher! Thank you for all your hard work :)
Wow that was great ,thank you..
Wonderful video.
your all videos are very very useful 👍
This real makes fun with dictionary comprehension for doing own private project
beautiful... thanks.. .. I like your extra efforts to make these videos enjoyable with nice editing and awsome graphics
Super Enjoyed and Laughing !! 😀😀😀
Hey Mariya
This video will help many💙🙃❤️
Thank you for this video Mariya, it's really helped me in my journey
Uau! Amazing!
Cheers from México 💋
I'm a Mariya simp :) :) lol your videos are an excellent supplement to my college courses! Thank you for all your hard work!
I think it would probably be faster to use the zip method. Two primary reasons, one being that with the range approach you have to check the list on each iteration, and two being since the zip function was probably programmed to do this efficiently it has a different method of accessing the objects. Just my guess!
well explained
My intuition tells me that range approach is faster, because zip approach must contain the procedure to compare between names and profs. Im a newbie for Python programming. Thank you for your videos, that help me a lot to learn Python.
Thank you so much for your comment Takeshi! 😃
I'm planning a live stream in which we will compare the two approaches! my intuition also tells me range() - however, with Python 3, the zip() approach is also very efficient so I'm expecting a very close battle 😉
Super👍🏻💕
Lovely as always Mariya.
I would like to point out that using the random module isn't safe for generating passwords. People might use it to generate passwords for their various accounts online. You could mention the secrets module which is advised and secure. Anyway keep up the good work. Love you ❤️
Thank you so much for the awesome tip, TechieGuy! 😃
Secrets is indeed much more randomized than Random! the only issue is - I couldn't find a secrets.choices() method but rather secrets.choice() which returns a single value instead of k of them.
From my perspective, the last exercise seemed convoluted enough to avoid the additional list comprehension of:
password = "".join([secrets.choice(string.printable) for i in range(8)])
That's why I went for Random instead... however - if this was a dedicated video for random passwords I'd definitely use Secrets instead 😉
If it's just a simple code, go and use list/dict comprehension, but when you logic become more complex, you better write it the old way, it's lot easier to read. Just like lambda for simple function and not for complex function.
great video!! thank you. You're a super teacher about python, it's easy with you!! . 3:15 I Think zip is faster than len
Thank you so much for your comment David! We will compare zip() and range() in an upcoming live stream, we'll see exactly which of them beats the other 😉
Hi, Sunshine ! 🌞😉👌
Very good !
I'd expect the "zip" method to be the faster one because it was purpose-made for such cases
and probably has some built-in optimizations, no?
Also the list comprehension where we add "man" works without putting (key, val) in brackets.
Wow, what a nice CZcams channel. Nice to see you, Mariya!
please more video ...❤❤❤❤❤
3:15 I think the zip approach is faster because the syntax is more comprehensive
Trop forte cette merveilleuse dame
very good very clever, very helpful.....but i rarely use these comprehensions and it would be faster for me to do it the long way than sit down to memorise the rules...then forget them.
Happy teacher day mam
Requesting for a data structures and algorithm playlist
Will do! I'm waiting to finish my current Algorithms and DS 2 module in university before I can properly cover the topic 😉
(My final exam is in September, so not much longer to wait 😊)
@@PythonSimplified Great, And all the best for your exams tho you gonna score 10/10 anyways
I became mad after watching this video. But you are a great tutor. I became a fan of you. Love you and your English. Thank you so much🧐😵💫🤒. I request you to please start a complete python tutorial for beginners.
Will you please explain in separate video about how to read multiple elements from user at time using split function . 2. How to sort a dictionary without converting to tulle
Cool
NIce to see again - greets from Germany.
Thank you so much George Orwell! Huge fan of your 1984 book 😉 hahaha
Greetings from Vancouver! 😃
🍓⭐high quality
Password generation code (in my tests) may produce a string with one or more spaces. Used replace to get rid of those.
That was my original plan, Dimitri! 😃but then I thought to myself - what's the problem with spaces? I couldn't find a single reason why they would be any different from the rest of the characters 🤷♀️
Some sites do prevent you from using spaces within passwords - but I don't think it's based on merit. Do you find that space-less passwords are more secure?
Because string.printable contains whitespace \t,
,
, at first i used to cut it at the end when i imported it, but for me better aproach was change the original string module and create printable_ww same but without white space, i would like to contribute to open source to change that for python 3.12 if comunity accepts it
Hi Mariya
I like your CZcams channel for Python
Hey Mariya~!
Thank you beautiful smart lady!
Another solution to the list of dicts problems:
import random as r
from string import printable as p
from pprint import pprint
users = ["Hanzo","Peter","Brian"]
keys = ["id","user","password"]
pprint([dict(
id = i,
user = user,
password = "".join(r.choices(p,k=9))
) for i,user in enumerate(users)])
😍
Hello this tutorial is excellent, do you have a python beginner course?
I'm not a Python programmer, but I like your videos
Thank you so much Guilherme!! 😃 I might end up convincing you to start using Python... I have some really exciting projects in the making 😉
Thanks for another video if you can in the future make python with MySQL some mini project tnx. 😀
Hi Sem 😃
MySQL is definitely on my to-do list! will cover it in my Linux machine in future tutorials. In the meanwhile, you can checkout my SQLite tutorials:
⭐ SQLite Backend for Beginners:
czcams.com/video/Ohj-CqALrwk/video.html
(please note - the above tutorial is missing connection.commit())
⭐Web Scraping Databases with Mechanical Soup and Sqlite:
czcams.com/video/MkGQmZoMuRM/video.html
(includes connection.commit() which is very important!)
It's not exactly MySQL, but it's right off the same alley 😉
I think the range approach is fastest.
In the DNA example, to simplify the code, I would create a dictionary:
pair = {"A":"T", "C":"G", "G":"C", "T":"A"}
Then, instead of the nested if statements, do
dna = {key:[val, pair[val]] for (key, val) in enumerate(strand1)}
Agree, I felt a little excesive use of ternerary operatrors.
I think it should be .. pair[val]] .. but could be wrong.
@@colinclarke3338 Yes it should, I've edited it now. 😳
Wow!! This looks awesome Katrina!! Great job! I love it! 😃😃😃
I've done it in a similar way:
dna = {idx:[b, {'A':'T', 'T':'A', 'C':'G', 'G':'C'}[b]] for (idx, b) in enumerate(strand1)}