Make Menus In Python with While True Loop | Choose an Option in Python

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 54

  • @FabioMusanni
    @FabioMusanni  2 года назад +2

    💻 *Source Code:* www.buymeacoffee.com/fabiomusanni/e/185771
    ⬇️ *LEARN ON THE BEST LEARNING PLATFORMS (LINKS BELOW)* 😉💪 ⬇️
    ☕ *Buy me a coffee:* www.buymeacoffee.com/fabiomusanni
    ❤️ *Support me monthly:* www.patreon.com/FabioMusanni
    😍 *One-off donation:* www.paypal.me/FabioMusanni/
    ⚠️⚠️⚠️ In the program I used exit() for simplicity's sake but you should always use the following instead:
    import sys
    sys.exit()
    *SKILLSHARE*
    _(Python, Web Dev, UI/UX Design, Music, Art, Animation and a lot more)_
    🔗 skillshare.eqcm.net/5gxzD2 (Affiliate)
    *DATACAMP*
    _(Python, ChatGPT, SQL, Power BI, and a lot more)_
    🔗 datacamp.pxf.io/vN1bDj (Affiliate)
    *COURSERA PYTHON*
    _(For beginners, Data Science, Data Analysis, AI, Cybersecurity and a lot more):_
    🔗 imp.i384100.net/k0Nk60 (Affiliate)
    *COURSERA WEB DEVELOPMENT*
    _(Full Stack, Front-End, Back-End, Web Design and a lot more):_
    🔗 imp.i384100.net/EKWxBW (Affiliate)
    Thank you for the support!❤
    🎥All my videos about Python: ruclips.net/p/PLs8qUrmRvaR0IT4IwJl-LSweAdACW-yLK

    • @Papaszita01
      @Papaszita01 2 года назад

      pls give the code :(

    • @FabioMusanni
      @FabioMusanni  2 года назад +1

      Hello Simisonka,
      I strongly recommend you to write the code yourself especially if you are trying to learn something, if you copy and paste a piece code without really understanding the concepts behind it, you won't be able to learn things properly. Furthermore, writing the code yourself will also help you learn it better and faster 😊

  • @cbmobile1797
    @cbmobile1797 Год назад

    This has to be the best tutorial about menu making I've ever seen

    • @FabioMusanni
      @FabioMusanni  Год назад

      Thank you for the comment! I'm glad you think so💪😍

  • @ivansanzeev
    @ivansanzeev Год назад +2

    Thanks, you are amazing. You have done these steps more easier withou starting with while.... and include while later
    Great

    • @FabioMusanni
      @FabioMusanni  Год назад +1

      Hey, thank you for the comment! 🥰 Yes, I thought it would be easier for people to understand and you confirmed that. I'm glad it was helpful 🤩💪

  • @airemeklar
    @airemeklar 11 месяцев назад +1

    Hello fabio! Thank you for this vid! but I have a question, after the first BREAK, I added my options (the if user_input..) I followed all your instructions and after I was done putting all the options, I tried running it but it only seems to break and ask for the name again of file/folder, I tried correcting again and again but It only breaks and I had no problems while putting the options, why does it not function well?

  • @structural-legacy
    @structural-legacy 5 месяцев назад

    Very Nicely Explained The Entire Concept...... Expecting More Conceptual Videos....

    • @FabioMusanni
      @FabioMusanni  5 месяцев назад

      Thank you for the comment! really appreciated! 😊😍

  • @structural-legacy
    @structural-legacy 8 месяцев назад

    Yes you have nicely explained the concept....
    Thanks for all your efforts...

    • @FabioMusanni
      @FabioMusanni  8 месяцев назад

      Glad you liked the video! 😍💪
      Btw, remember you can find the source code of my videos and support the channel here: www.buymeacoffee.com/fabiomusanni

  • @johnwil5844
    @johnwil5844 Год назад +1

    Hello Fabio how do i fix because break isnt recognized or it is blocked by Pylance

    • @FabioMusanni
      @FabioMusanni  Год назад

      Hello, sorry for the late reply but I didn't see the comment.
      I don't know if you've already fixed this but I've never seen something like that. "break" is a Python basic keyword and it's strange that Pylance doesn't recognise it.

  • @memenadekhanh3992
    @memenadekhanh3992 Год назад +3

    not all heroes wear cape.

    • @FabioMusanni
      @FabioMusanni  Год назад +2

      Thank you very much! Much appreciated! 🙏🏻 ❤️

  • @manomund3335
    @manomund3335 6 месяцев назад

    Nice video bro.
    Love from india🇮🇳

    • @FabioMusanni
      @FabioMusanni  6 месяцев назад

      Thank you! Really appreciated! 😍💪

  • @Krooztech254
    @Krooztech254 Месяц назад

    Can i use method to run my python working code functions of 5 programs

  • @maciejmaniu5304
    @maciejmaniu5304 Год назад +1

    Hi Mate! Thanks for the video! It helped me understood while loops. However I may have one question. I was following it while using jupiter notebook and it did not work. It looped on "select an option" all the time. Do you know why? I had to do it in .py file to actually make it works.

    • @FabioMusanni
      @FabioMusanni  Год назад +1

      Hey mate! Thanks for the comment! 😉
      Are you saying that it didn't work and when you added the .py it started working? I'm asking just to make sure I'm understanding correctly.

    • @maciejmaniu5304
      @maciejmaniu5304 Год назад +1

      I managed to find out that while using jupyter notebook 'exit()' does not work. I had to change it to break. However the biggest issue seems to be with jupiter extension for vsc because sometimes there is no menu at all, sometimes you need to select option twice and so on. I pasted the same code to anaconda jupyter notebook and it works fine.
      When working in .py it works withou any issues.
      Once again, great video. The first one I could figure out just like that!

    • @FabioMusanni
      @FabioMusanni  Год назад +2

      As I pointed out in the pinned comment, it's better to "import sys" and use "sys.exit()", maybe that would have worked. But yeah, I guess there is something wrong with the extension, I'm glad you managed to figure that out and also that the video was helpful! Keep it up! 💪😉

  • @WildBite
    @WildBite 2 года назад +2

    Hi Fabio, thanks for your video! It has helped me a lot with an assignment.
    I have a question, hope you can help. Let's say we wanted the program to start over once each of the options is done doing what it's meant to be doing, how would you do that? By placing the if-elifs inside the while True loop? I get really confused with loops (total newbie here!) so I don't know how to approach this. Any suggestions will be greatly appreciated!
    Oh and for the record, I've subscribed, liked the video and watched the ads. :)
    Thanks! ~ Jules

    • @FabioMusanni
      @FabioMusanni  2 года назад +1

      Hello Jules ☺️
      First of all I'm happy that the video helped you and thank you very very much for the kind words, the subscription, like, etc. Really appreciated! ❤️
      As far as the question, at min 4:35 I define a function that you can then use later on (5:56) to do exactly what you asked for. You need to use two while True loops (one in the menu function and one for the options). Let me know if it's what you asked for 😊

    • @WildBite
      @WildBite 2 года назад +1

      @@FabioMusanni Hi Fabio :)
      Thanks for your reply and for the explanation, you're a legend! ❤
      I managed to sort it out yesterday after some hard stackoverflowing, lol.
      Keep up the good work! I'm sure your channel will continue to grow.
      ~ Jules

    • @FabioMusanni
      @FabioMusanni  2 года назад +2

      Thanks again Jules! 💪😉 ❤
      See you in my other videos! Cheers 🤗

  • @Aternos_the_alfamous
    @Aternos_the_alfamous Год назад

    Hi there! I'm a pydroid 3 user (aka python for mobile user). If you follow the video in pydroid 3, it may occur a loop if you answer an invalid value/options. I need some solution for that and thanks for your video btw. Edit: I found a solution by now, you can add user_input=input("") right under print("Invalid option") so it wont continue to loop but instead telling us invalid option until it gets a valid option

    • @FabioMusanni
      @FabioMusanni  Год назад

      Hey, thanks for the comment. 😊
      As far as I know pydroid 3 is an IDE for Android, for that reason you should get the same exact result without changing anything, unless there is a bug or something doesn't work right in the IDE.
      That said, I'm glad you found a solution to make it work, well done 😉 💪

  • @Silvertestrun
    @Silvertestrun 6 месяцев назад +2

    Thank you

    • @FabioMusanni
      @FabioMusanni  6 месяцев назад

      Thank you for the comment! 😊💪

  • @fernandasori5609
    @fernandasori5609 2 года назад

    You are good ! Thanks

  • @LauraHerrera-c7q
    @LauraHerrera-c7q 8 месяцев назад

    Gracias. Tu video me ayudo con mi tarea.

    • @FabioMusanni
      @FabioMusanni  8 месяцев назад

      Gracias por el commentario! Me alegro de que el video te haya ayudado. 💪😍
      No olvides que puedes apoyar el canal y obtener el código fuente de mis videos aquí: www.buymeacoffee.com/fabiomusanni

  • @Johnitus69
    @Johnitus69 Год назад +1

    Thank you!!!! omg

    • @FabioMusanni
      @FabioMusanni  Год назад +1

      Hey! Thank you very much for the comment!😍💪

  • @alexsmith5455
    @alexsmith5455 Год назад

    have you publish the entire code somewhere? thanks.

    • @FabioMusanni
      @FabioMusanni  Год назад

      Hello Alex 😊
      No I haven't, for one simple reason: I'm against the "copy and paste" because I think that, in order to learn properly, you need to listen to the explanation and at least write the code down yourself. By doing so you put a little more effort into learning and not, as a lot of learners do, just copy and paste without even understanding what the code does. I hope it makes sense 😊😉

    • @alexsmith5455
      @alexsmith5455 Год назад +1

      @@FabioMusanni Thank you for the fast reply.
      If understood correctly, you have a principle to educate the public rather than inform them and, as you stated on your channel, to teach beginners. However as a beginner, I found it hard to follow your video as you changed the indentation of certain lines, added lines without mention it at all! It’s preferred you let beginners an access to the entire code so they can better understand your explanations while watching your channel. Please reconsidered!

  • @nathanlunsford3017
    @nathanlunsford3017 2 года назад

    Thank you for the help! I was stuck on while combos in pltw❤

    • @FabioMusanni
      @FabioMusanni  2 года назад

      Thank you for the comment and I'm glad the video was helpful! 💪🤗❤

  • @abritnamedsethinnit
    @abritnamedsethinnit Год назад

    I tried this and it said 'break outside loop' when I tried it. My code matches perfectly, so can anyone tell me what's wrong? EDIT: It was because I didn't indent it enough, so just ignore this.

    • @FabioMusanni
      @FabioMusanni  Год назад

      Thank you for the follow up! I was actually going to reply that it was probably due to indentation and you confirmed it 😂😉

  • @similartoothers9154
    @similartoothers9154 Год назад

    Couldn't it be better if to use match/case conditions? I think it's more beautiful and professional

    • @FabioMusanni
      @FabioMusanni  Год назад

      In my opinion, there is no better way, as long as it's clear and does what it's supposed to do, and of course it's important to know both ways because the match statement is something new and you don't see it in old programs.
      I actually made a complete guide on the match statement ( ruclips.net/video/RvW1zJcd6oA/видео.html ) and even a video where I use it to make menus and commands ( ruclips.net/video/hnmqxC6fxQA/видео.html ) ☺☺

    • @similartoothers9154
      @similartoothers9154 Год назад

      @@FabioMusanni wow, thanks for so fast answer, I'll watch it

    • @FabioMusanni
      @FabioMusanni  Год назад

      @@similartoothers9154 No worries! 😊 Hope the videos are helpful! 💪🤓

  • @AndalusiaChromatic
    @AndalusiaChromatic 2 года назад

    I've got syntax error.. 'break' outside loop..

    • @FabioMusanni
      @FabioMusanni  2 года назад +5

      Hello 😊
      Check the indentation because it's definitely a problem with that. If you get that error it means that the "break" is not indented with respect to the "while True:" and Python sees that "break" outside the loop and it raises that error.
      Example (---- = indentation)
      * RIGHT *
      while True:
      ----if ... in ...:
      --------break
      * WRONG *
      while True:
      ----if ... in ...:
      break
      As you can see the wrong version has the "break" at the same level of indentation as the "while True:", and it's considered outside of the loop. I hope this helps, let me know if you figure this out 💪

  • @Volcan-kf3oz
    @Volcan-kf3oz Год назад

    Why didn't he just do "print('
    ** Menu **')" instead of putting an empty print() ? Just curious

    • @FabioMusanni
      @FabioMusanni  Год назад +2

      I just felt like doing it that way 😁 There isn't a reason, you can do whatever makes you happy. This is the cool thing about programming, you can do the same thing in different ways and you can choose the one you like the most 😉 The important thing is that it makes sense and works.

  • @kcbrick1524
    @kcbrick1524 6 месяцев назад

    I copied every damn Letter from him to test if it Was my fault that it didnt wirk but it still didnt work
    I spent a lot of time for nothing

  • @TheGorilla58
    @TheGorilla58 7 месяцев назад

    Too long .... use case