Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Functions: Miscellaneous

Give Feedback

Comments & Discussion

kenyonej on April 13, 2020

Hi, I heard you say don’t put [] at the end of the code, what is the purpose of brackets, or may i ask, when or when not to use brackets? I know they’re used to create a list, but what other scenarios do we need to use them? Sorry if i missed your explanation of this…

Darren Jones RP Team on April 14, 2020

Hi. Can you point me to the time that you’re referring to for some context? [] will typically be used to either create a list (whether in a comprehension or direct assignment, but also for indexing elements or slices. They’re often used to access dictionary items:

my_dict["one"] = "Ein"

but using the .get() method of the dictionary is generally a safer way to work.

kenyonej on April 16, 2020

Hi Darren,

I should’ve made note of the reference to which video at which time when you indicated it, but you are correct, you could’ve been simply referring to the context in which you used the []. I didn’t make note of it, so I’d at least have to go through the module again and listen. But, your explanation actually answers what I was asking. Thanks!!

Adam on May 3, 2020

it is very clear explanation.Thanks

eleven2 on May 18, 2020

at time 5:30 it was. What Darren meant was not to use pow() as a dict value, rather pow without (). print(eval(calc, {‘pow’:pow()})) would not allow to use the function itself.

jckichuk on July 4, 2020

Hi Darren, when checking if too strings are the same, why bother hashing them first? Does python not allow direct comparisons between the strings themselves? Could you not print(moby_1 == moby_2) ?

Become a Member to join the conversation.