5 Common Python Mistakes and How to Fix Them

Sdílet
Vložit
  • čas přidán 13. 09. 2024
  • This video is sponsored by Skillshare. Be one of the first 500 people to sign up with this link and get 2 free months of Skillshare Premium:
    skl.sh/coreysc...
    In this Python Programming Tutorial, we will be going over some of the most common mistakes. I get a lot of questions from people every day, and I have seen a lot of people making these same mistakes in their code. So we will investigate each of these common mistakes and also look at the fixes for each other these as well. Here are the timestamps for each topic we will cover...
    1) Indentation and Spaces - 0:45
    2) Naming Conflicts - 4:12
    3) Mutable Default Args - 10:05
    4) Exhausting Iterators - 16:35
    5) Importing with * - 22:13
    PATH Tutorial - • Python Tutorial: How t...
    Iterators Tutorial - • Python Tutorial: Itera...
    Generators Tutorial - • Python Tutorial: Gener...
    ✅ Support My Channel Through Patreon:
    / coreyms
    ✅ Become a Channel Member:
    / @coreyms
    ✅ One-Time Contribution Through PayPal:
    goo.gl/649HFY
    ✅ Cryptocurrency Donations:
    Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
    Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
    Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
    ✅ Corey's Public Amazon Wishlist
    a.co/inIyro1
    ✅ Equipment I Use and Books I Recommend:
    www.amazon.com...
    ▶️ You Can Find Me On:
    My Website - coreyms.com/
    My Second Channel - / coreymschafer
    Facebook - / coreymschafer
    Twitter - / coreymschafer
    Instagram - / coreymschafer
    #Python

Komentáře • 214

  • @coreyms
    @coreyms  Před 5 lety +120

    If my voice sounds a bit off then it's because I'm getting over a cold. I hope everyone finds this overview of these common mistakes useful. To save you time, I put a list of the common mistakes and the timestamps for each in the description of the video. And again, this video was sponsored by Skillshare. If you'd like to check out Skillshare with 2 free months of Skillshare Premium, you can use my link here:
    skl.sh/coreyschafer2

    • @akashshetty6422
      @akashshetty6422 Před 5 lety +4

      Take care sensei !

    • @sandeepvk
      @sandeepvk Před 5 lety +3

      Kindly make these videos shorter max 15 min. I can assure you more views

    • @danielturunen7237
      @danielturunen7237 Před 5 lety +1

      THANK YOU! I surmised that tabs and spaces don't mix because i'm just starting out with programming and in spite of looking I could not find a definitive anser to this question. It would have saved me a metric ton of headache had you made this video sooner so, FYI, its YOUR fault that my head hurts so much! :) Thanks! :D

    • @richaverma320
      @richaverma320 Před 5 lety

      hey your voice is perfect but you increased the speed and it is creating problem

    • @coreyms
      @coreyms  Před 5 lety +5

      @@richaverma320 I didn't increase the speed. I just naturally talk a bit fast

  • @archstampton5910
    @archstampton5910 Před 5 lety +152

    "Default arguments are only executed once when the function is declared " You made my day, thanks Corey !

    • @emmanuelevbuomwan2665
      @emmanuelevbuomwan2665 Před 5 lety +18

      Not when the function was declared, but when it was first run/called.

    • @gildaslefur2435
      @gildaslefur2435 Před 4 lety +2

      @@emmanuelevbuomwan2665 yes, thank you. This makes more sense!
      [Edit] Sorry for ressurecting this 1-year old comment.

    • @ReddoX30
      @ReddoX30 Před 4 lety

      Yes, it helped me from a lot of trouble!
      Thanks Corey!

    • @sakon4466
      @sakon4466 Před 3 lety

      lol

  • @alexweissnicht9545
    @alexweissnicht9545 Před 5 lety +300

    For mobile users:
    1) Indentation and Spaces - 0:45
    2) Naming Conflicts - 4:12
    3) Mutable Default Args - 10:05
    4) Exhausting Iterators - 16:35
    5) Importing with * - 22:13

    • @coreyms
      @coreyms  Před 5 lety +36

      Mind if I ask you how you did that? I didn't know I could get clickable timestamps on mobile.

    • @alexweissnicht9545
      @alexweissnicht9545 Před 5 lety +16

      @@coreyms They are only clickable in the comment section, the ones in the description don't work 🙃

    • @alexweissnicht9545
      @alexweissnicht9545 Před 5 lety +5

      @@coreyms Besides that they are the same

    • @coreyms
      @coreyms  Před 5 lety +57

      Ah, interesting. Thanks for the reply! I'll be sure to add description timestamps to my pinned comments from here on out. I appreciate the tip.

    • @alexweissnicht9545
      @alexweissnicht9545 Před 5 lety +18

      @@coreyms I appreciate the content🙃

  • @kaydenstevens5193
    @kaydenstevens5193 Před 4 lety +29

    Dude your channel is fantastic. I've taken two college courses so far where we used python and I always wished the professors would teach us the fundamental tricks of the trade. They didn't. They only taught about the big concepts like Encapsulation, Inheritance, Polymorphism, Algorithms, Data Structures etc.. which is obviously important to learn but I feel like the basics are so critical yet overlooked in the curriculum. Thankfully your channel is available for us to learn. Thanks!

  • @FirdausAziz
    @FirdausAziz Před 5 lety +16

    Thanks Corey. That empty list as default argument lesson is really great. I appreciate it very much.

  • @farleyfarleyfarley
    @farleyfarleyfarley Před 5 lety +47

    Thanks for all the work you're putting in on these lessons, Corey! I love seeing a CZcams alert that you've posted a new video.

  • @toki_doki
    @toki_doki Před 5 lety +8

    That naming conflict issue caused me so much confusion in the past. Nice tips Corey.

  • @markjago2269
    @markjago2269 Před 4 lety +7

    Great video, but there is a subtle fallacy: in Mutable Default Args at 13:39, Corey says, incorrectly, that you can equivalently write "if not emp_list" instead of "if emp_list is None". With the "if not emp_list", if we feed the add_employee function with an empty list emps, the name will not be appended to emps. Thus, "... is None" and "not ..." are not always interchangeable.

  • @noxlaoy5119
    @noxlaoy5119 Před 5 lety +3

    Pitfall No. 2 was literally me a couple of weeks ago! :) I tried out a package and _of course_ I named my testing script file after the package itself!
    Thanks for making this video, I really appreciate your effort. And it shows: this video feels concise but still in-depth; I can easily follow your thoughts and arguments. This is one of the best tutorials videos I have seen so far. This very video is what makes youtube such an amazing place!

  • @MarcMcRae
    @MarcMcRae Před 4 lety +3

    Always learn something new from your videos, even stuff I didn't know I wanted..lol. Great videos Corey mate!

  • @narendrasudrik5073
    @narendrasudrik5073 Před 3 lety +1

    You are excellent teacher Corey. Many thanks for crisp and clear information with apt words.

  • @garydunken7934
    @garydunken7934 Před 5 lety +3

    Nice, I love it. I'm learning new things in Python all the time. Please keep up these videos. Thanks Corey.

  • @edydon
    @edydon Před 3 lety +1

    Great work - the mutable default argument issue is commonly asked on quizzes

  • @juangamboa2646
    @juangamboa2646 Před 4 lety +1

    Thanks Corey, your videos have helped me to build clear python foundations. I always get to your channel for clarification and learning! Excellent work

  • @vivac4893
    @vivac4893 Před 2 lety

    this video you made is one of best to resolving our problems during learning your course

  • @sarthakvashisth9817
    @sarthakvashisth9817 Před 5 lety +2

    Awesome video Corey. I just got the notification and watched it. Your videos are very good. I just shared your channel link to all my colleagues and friends who truly wanted to learn python. Keep up the good work brother. ..!

  • @erikjohnson9112
    @erikjohnson9112 Před 5 lety +7

    When I saw this title I was going to suggest mutability understanding/awareness, especially with regards to default values. Bingo, it already made your list. Nice.
    As a programmer coming from C++ and learning Python later, this was the most important unexpected thing I learned from the Learning Python book (a good book for learning Python from a single book).

    • @erikjohnson9112
      @erikjohnson9112 Před 5 lety +1

      Also I've been away from Python for a bit and only lightly used generators so exhausted generators related to changes from Py2 to Py3 was new info for me.

  • @MrTigerstyle80
    @MrTigerstyle80 Před 4 lety +3

    You should cover circular import dependencies in one of your videos. That’s always a good refresher.

  • @finix7419
    @finix7419 Před 2 lety

    thank you ,been a short sweet ride with your beginner tutorial and already feel like I learned alot ,now time to move to the longer 143 part playlist !

  • @MustbeTheBassest
    @MustbeTheBassest Před 4 lety +1

    Wow, this was amazingly helpful!
    I had no idea about that default args problem...
    And the iterator exhaustion issue seems super helpful for future hair ripping sessions!

  • @khaled-dz8357
    @khaled-dz8357 Před měsícem

    the best pythonist ever. thank you corey

  • @olha_
    @olha_ Před 5 lety +2

    This cleared up some things for me, thanks so much Corey!

  • @ItzSenaCrazy
    @ItzSenaCrazy Před 5 lety +2

    Nice video!!
    Continue with this quality.
    Thank you!

  • @jingyuchang1885
    @jingyuchang1885 Před 5 lety +2

    I did notice your voice is different than normal. I was thinking it was my computer's issue. Well, great video again!! Hope you get better soon!!

  • @masterlifestyle4591
    @masterlifestyle4591 Před 4 lety +1

    Love the video Corey keep them coming!

  • @zprelude9935
    @zprelude9935 Před 4 lety

    Impressive to watch these tips which I'm not aware so long time..especially naming convention potential risks...Thank you !

  • @Arrowtake
    @Arrowtake Před 5 lety +1

    Yet another Great video. Always learning somthing new. Thanks!

  • @nurashams4093
    @nurashams4093 Před 5 lety +4

    thank u for uploading...i like ur django series....besides ur presentation and voice is so much standard for an ideal lecturer. could u plz upload some video on pygame, threading and multiprocessing.?..a new series may be....

  • @ShuiYueSketchbook
    @ShuiYueSketchbook Před 4 lety

    You're really helping me out! I am super grateful!

  • @gauthamambethkar4483
    @gauthamambethkar4483 Před 3 lety

    Thanks corey. I had this problem of saving the file name same as the module in standard library and could not find out what the error is. Thanks again for saving my time

  • @alapierre1
    @alapierre1 Před 2 lety +4

    When a function expects an argument to be a reference to a function and you mistakenly add ()’s to the function name which then calls the function, it can be difficult to find the problem in your code.

  • @gabriel_felippe
    @gabriel_felippe Před 5 lety +1

    Always the best! Thank you Corey!

  • @greob
    @greob Před 5 lety +1

    Very nice video, good tips. Thanks Corey!

  • @melkoss92
    @melkoss92 Před 2 lety

    Really useful stuff! Thanks Corey!

  • @JoshyHJoshy
    @JoshyHJoshy Před 5 lety +1

    Great tutorial. Thank you Corey.

  • @codegeek8256
    @codegeek8256 Před 5 lety +1

    I love your videos...please keep them coming they are very helpful

  • @zabiullahs.z9867
    @zabiullahs.z9867 Před 3 lety +1

    I would be the happiest man in the world if you make it a series

  • @therimalaya
    @therimalaya Před 5 lety

    Looks simple but could give a lot of headaches. Thanks for the video.

  • @bdafeesh
    @bdafeesh Před 5 lety +2

    Woow I didn't know about the default argument one. That's bizarre behavior you don't see in other languages...I need to go back and check some things now lol

  • @truthhorizon5851
    @truthhorizon5851 Před 3 lety

    Thank you very much .This was very helpful to me.

  • @samehmahmoud7
    @samehmahmoud7 Před 5 lety +1

    Thanks Corey, useful video

  • @Talon_24
    @Talon_24 Před 5 lety +1

    Stumbled aboud the second one a while ago, took waay too long to figure out what happened there..
    asterisk-import: another example that can happen is if you import sys and os, both have a 'path' member, these two might be found a little more often than glob and html
    Thanks for the video! :D

  • @squigglyunicorn7777
    @squigglyunicorn7777 Před 4 lety +1

    Thank you, very helpful!

  • @neilfpv
    @neilfpv Před 4 lety +1

    Amazing gotchas! Thank you sir!

  • @Victor_Marius
    @Victor_Marius Před 5 lety +1

    Thanks a lot for that setting! I thought tabs were already translated to spaces (at least when writing html and js). Now I don't have to worry about tabs in python neither

  • @jaikishank
    @jaikishank Před 4 lety

    Thanks . The tips were quite useful.

  • @morethanprogrammer7594
    @morethanprogrammer7594 Před 5 lety +2

    This is the best resource for improving at Python.
    PS. Maybe a vid on practice interview questions in Python? Very relevant at the moment (for me haha).
    Thanks once again!

    • @coreyms
      @coreyms  Před 5 lety +2

      I have an older video on Python Interview Tips. You can find it by searching my channel. I really would like to make an update video though, because I feel like it's not one of my better videos. I would definitely do it differently if I remade it today. I do plan on making one at some point in the next couple of months though.

    • @morethanprogrammer7594
      @morethanprogrammer7594 Před 5 lety

      ​@@coreyms Thanks for the reply. I've searched the channel for "Interview questions" I believe, saw that video there yeah, but didn't watch it yet.
      I was thinking more actual practice questions, but again maybe you have that in the vid. I'm gonna watch that one for now.

  • @abail7010
    @abail7010 Před 5 lety +2

    Wow! I actually have a developer job since 5-6 months and the thing with the default list screwed me up 😂
    Great video, you’re really helping people out!

  • @JohnPurcell
    @JohnPurcell Před 5 lety +1

    Learned a bunch! Thanks!
    A question about default arguments. Overuse of NoneType causes a lot of bugs in my team's code. We've insisted in many places to initialize optional args to avoid type switching. I was not aware of the buggy behavior you outlined, but the `if val is None` pattern adds a lot of boilerplate for more complex functions. Do you have any more advanced notes on how to keep my mid-level pythonistas from getting burned?

  • @dalchemistt7
    @dalchemistt7 Před 4 lety

    Naming your string as str or a list of things as list is a sure shot way of getting crazy...

  • @சதீஷ்கண்ணன்

    I would like to know some channel teaches Java as neat as Corey does here in Python.. 👏👏
    People can suggest your options pls.. 😊😊

  • @mahmedtuny8174
    @mahmedtuny8174 Před 4 lety +1

    Thanks

  • @peluso_palit
    @peluso_palit Před 5 lety +1

    Thanks for Skillshare. I just signing up to explore the courses :)

  • @marco.nascimento
    @marco.nascimento Před 5 lety +1

    Great tips!!

  • @mr.anderson5393
    @mr.anderson5393 Před 4 lety +1

    Good day sir. Do you have any videos on string , bytes, encoding , and decoding?

  • @TrumanBurbonk
    @TrumanBurbonk Před 5 lety +2

    Great video! I should watch more of Corey's videos.

  • @orisphera
    @orisphera Před 3 lety

    18:20 I would also say that unzipping in a for loop (for name, hero in identities) doesn't work in Python 2 either

  • @DonAlcohol
    @DonAlcohol Před 2 lety

    the weird thing is that i often use default mutable (kw)arguments exactly for that reason, the "data" stays with the function, but it "remembers" its past runs, by the first part i mean it saves you having to pass a variable around form one function to another wich can be a hasle to do if the function is getting called in multple places but every call needs to be aware of what happened before , the goto way of negotiating this would be to use a global but indeed globals.... and theire problems , one of them being you dontalways think to check for them or remember/find everywhere they are set or changed, but using a mutable (kw)argument is always there with the function definition. (sidenote : i avoid writing classes for stuff that shouldnt be a class or even stuff that can be done without a class like the plague wich wich would be the goto way of OOP-style programmers instead of globals)

  • @jims408
    @jims408 Před 5 lety +1

    Very helpful, thanks for sharing! I've been using Python for years, mostly v2 and this helps push me to switch 100% to Python v3 so I can curb my old bad habits.

  • @baspass8578
    @baspass8578 Před 4 lety

    Hi Corey, please make video on multiple inheritance and common problems associated with it

  • @PanicProvisions
    @PanicProvisions Před 5 lety +1

    Aaaargh, you bastard. I paused the video at the first example and was staring at the code, wondering where the hell the problem was supposed to be! xD

  • @nagaranjith9147
    @nagaranjith9147 Před 5 lety +1

    Hello Corey... Could you please make videos on data structures and algorithms

  • @shanvantharunmozhi
    @shanvantharunmozhi Před 3 lety

    the list thing was very useful

  • @baconsledge
    @baconsledge Před 5 lety +1

    great tips!

  • @s.baskaravishnu22
    @s.baskaravishnu22 Před 3 lety

    Many thanks

  • @prabhathkota107
    @prabhathkota107 Před 5 lety +2

    Default arguments was a surprise, good one 👍

  • @shaiavraham2910
    @shaiavraham2910 Před 5 lety

    I just realized that help actually prints the help messages and doesn't return them as a string because it printed None on 25:50. Good to know.
    Also, you could have used to "from os import *" and show how reading a file fails because of the clash with os.open. Good video anyways.

  • @omar72999
    @omar72999 Před 5 lety

    One of the problems I faced early on was that I was installing packages using PIP, and then when I would try to import those packages with VS Code it'd tell me that these packages were not installed. After doing some digging I ended up finding that I was installing those packages for an older version of Python (3.6), and trying to compile my code with a 3.7 interrupter. Maybe you should mention this in one of your future videos. I feel like this could be an issue that some people will struggle with for a while.

    • @coreyms
      @coreyms  Před 5 lety +1

      Hey there. Good point. I have done a video on that topic “PATH issues”. But you’re right, it would be good to have pointed that out a bit more

    • @omar72999
      @omar72999 Před 5 lety

      Corey Schafer oh my apologies. I didn’t know that there was already a video on this topic. Thank you I’ll give it a watch!

  • @MmmBopsPops
    @MmmBopsPops Před 5 lety

    14:52 - Wow, that is REALLY annoying. Coming from PHP, this would have driven me mad, and probably still will! Thanks for sharing.

  • @ivanabregu1
    @ivanabregu1 Před 5 lety

    Thanks man, did you do some video about PEP8?

  • @lindaphan9234
    @lindaphan9234 Před 4 lety

    Thank you so much!

  • @angeljiminian5305
    @angeljiminian5305 Před 5 lety

    Thank you for your videos.
    I am about 1 1/2 months new to Python. I saw this video and went back to look at some of the self-learning I've been doing. I found a way, actually, I am sure I copied some code and modified it today to see if it would work. I can't tell you why it works but it works. I guess I better figure out why it works so I can feel confident in coding.
    I am using Pycharm latest version. I am using Python 3.7 on a Windows 10 machine.
    import time
    from datetime import datetime
    def display_time():
    t = time.strftime('%Y-%m-%d (%I:%M:%S %p)')
    print(t)
    time.sleep(1)
    display_time()
    time.sleep(1)
    display_time()
    time.sleep(1)
    display_time()
    My result was the result you got after you fixed it.
    Please, some smart person explain why it works, I don't have the knowledge to do it.

    • @coreyms
      @coreyms  Před 5 lety

      You’re not using arguments to your function there, so everything within the function will get run every time the function is run.

    • @angeljiminian5305
      @angeljiminian5305 Před 5 lety

      @@coreyms is it pythonic to do it the way I did it or is it frowned on?

  • @reef2005
    @reef2005 Před 4 lety

    Regarding the emp_list=[], it's run once. But why its value is kept for the next run? This is a variable that is local to the function and should disappear at end of each run of the function.

    • @trueriver1950
      @trueriver1950 Před 3 lety

      Two points that interact in ways that seem quirky till you "get" the Python idiom.
      The default value is remembered from creation of the function.
      The default given and remembered is mutable: that means if you change the value you have changed the default.
      In C terms think of it as the address which at the time of creation points to an empty linked list. If you add to the list the address remains the same but the contents vary. The implentation is not quite the same, but that's the basic idea.
      That idea is helpful in making the transition from C (at least I found it so) but try to move on as soon as you can to thinking in Python terms: that that's just what mutable objects do: a mutable object can have different values over time.

  • @clayy.walker2108
    @clayy.walker2108 Před 4 lety

    it's useful thanks

  • @isbestlizard
    @isbestlizard Před 4 lety

    don't use 'if not emp_list:' that would also be true if you passed an empty list, meaning it would ignore an empty list you passed in, and always create a new one itself which might be surprising

  • @buuqmarabo2778
    @buuqmarabo2778 Před 5 lety +1

    thanks!

  • @luis96xd
    @luis96xd Před 5 lety +1

    This is and excellent video, well explained, Thanks!

  • @ruslash
    @ruslash Před 2 lety

    u said that tabs cannot b used for indents but in yr code it says that indentation error was found in line 6 which was the line u used spaces for indentation? 2:20

  • @736939
    @736939 Před 5 lety +8

    Corey, please start Scikit-Learn tutorials!

    • @gh0oo
      @gh0oo Před 5 lety

      Please don't. There are millions of tutorials on Scikit-Learn and it is likely not his field. Please keep doing your awesome Python and devops oriented tutorials which you're perfect at. I have personally learnt so much from you.

    • @736939
      @736939 Před 5 lety

      @@gh0oo there are million tutorials of Python, but everybody looking for Corey's tutorials!

  • @viswanathbodapati5711
    @viswanathbodapati5711 Před 3 lety

    Hey Dude.!! Can u please help to sort a list in an ascending order ..with taking two loops...

  • @Sam-uh8lb
    @Sam-uh8lb Před 3 lety

    I didn't understood what program you suggest to help us checking the errors

  • @RK_97
    @RK_97 Před 4 lety

    Hi Corey, is there a Numpy playlist in your contents, i couldn't find one in your website and in youtube

  • @Evangelistabryanantigua
    @Evangelistabryanantigua Před 4 lety +1

    Hey I created a simple turtle screen but when the screen pops up is says not responding. Any advice?

  • @Pecos0
    @Pecos0 Před 5 lety +1

    Good stuff. Only criticism is that it's Spider-Man. ;)

  • @aaronfisher5989
    @aaronfisher5989 Před 3 lety

    is there a command that deletes all indentation so you can re-indent, regardless of editor?

  • @SusanAmberBruce
    @SusanAmberBruce Před 5 lety

    Can you explain how to set up an exit function, to exit from a running python3 program from a users input (say shift plus key combination) without raising an error and giving a clean exit? I am thinking about a program running in idle.

  • @abhiganta
    @abhiganta Před 5 lety

    Saved me from too much frustration...

  • @playgoods
    @playgoods Před 5 lety +1

    thank you :)

  • @ginopornasdoro3081
    @ginopornasdoro3081 Před 5 lety

    can you make tutorial about getting certificate in django heroku deployment?

  • @JonJon2040
    @JonJon2040 Před 5 lety

    says not to name variables as module names (/ function names), names a variable time when importing the time module

  • @NathanTallack
    @NathanTallack Před 5 lety

    Mutable default args make recursion memoization nice and easy. ;)

    • @trueriver1950
      @trueriver1950 Před 3 lety

      They also make it easy to get unintended recursive effects...

  • @dennisalabi
    @dennisalabi Před 5 lety

    Thanks a lot for the effort you put into your quality videos, your teaching style is awesome but please can you do something on Django e-commerce website?

  • @PraveenRai
    @PraveenRai Před 5 lety

    @Corey Schafer i followed your sublime 3 steup video and setup as it mention but whenver i run code without any import statement i get error like this
    /usr/local/bin/python3: can't find '__main__' module in ''
    please help me to fix

  • @prakash1171
    @prakash1171 Před 5 lety

    WHY range is the wrong keyword for that prog and below prog not working.
    N = int(input("Enter your No. "))
    if (N % 2 == 0):
    if ( range(2,5)):
    print('Not Weird')
    elif(range(6,20)):
    print('Weird')
    elif(N > 20):
    print('Not Weird')
    else:
    print('Weird')

    • @hongfeemo6068
      @hongfeemo6068 Před 5 lety

      try:
      if (N % 2 == 0):
      if (N in range(2,5)):
      print('Not Weird')
      elif(N in range(6,20)):
      print('Weird')
      elif(N > 20):
      print('Not Weird')

  • @nayefhaque7401
    @nayefhaque7401 Před 4 lety

    Process " program 1" is running.
    Program 1 is not allowed to run in parallel. Would you like to stop the running the running one?
    Every time when i try to run a code this problem occurs, how can i solve this problem? Please someone help

  • @kareemjeiroudi1964
    @kareemjeiroudi1964 Před 4 lety

    Can you make a video about naming variables - programmer's hardest challenge 😅😂?

  • @tmduke55221
    @tmduke55221 Před 4 lety

    Hi I am so new to python, I am using "Python Crash course" 2nd edition by Eric Matthes. So I am learning step by step, I followed all instructions to install Python and Sublime text editor. So yes it does start off with Hell World, now when I did this for my very first time everything worked, and it worked a couple more times, then I took the next step of adding the variable and that is where I messed things up. I went back traced my steps but I could not get it to work. I took the final step of completely uninstalling Python and Sublime and reinstalling it. Problem is when the reinstall is complete and I open Sublime it still shows the old code , I was hoping that wiping everything out would clear the history as well but it did not.
    Now I am using windows 10 home edition, with a system type of 64-bits OS and X^$-base processor, and it is all running on a HP laptop . Now asking where I went wrong would be just silly, but I would like to know how to fix this or find out where things took a wrong turn.
    Reason I am learning python just because...

  • @leophysphile2898
    @leophysphile2898 Před 5 lety

    I have one question about the default argument. Why it reset the list to none each time you run the function?it contradicts with what you said that it runs the default argument one and only once.

    • @coreyms
      @coreyms  Před 5 lety +1

      It is still setting the values to the default value every time, but they are only evaluated once. So if it is set to a value like None then it will get set to None by default if no arguments are provided. But if it's set to an empty list then it will create that new list once, and then it will get set to that same list by default if no arguments are provided. Since lists are mutable, you will be able to see that original list being modified. You won't be able to tell with immutable data types because they can't be modified.
      I really like this explanation in this StackOverflow answer... I should have incorporated it into the explanation:
      stackoverflow.com/questions/10676729/why-does-using-arg-none-fix-pythons-mutable-default-argument-issue

  • @Void_is_Live
    @Void_is_Live Před 4 lety

    please help me how to fix badzipfile error using instapy

  • @xaco56
    @xaco56 Před 4 lety

    Instead of capturing the iterator items in a list, another way to access the items again is to call zip again.