Make Menus In Python with While True Loop | Choose an Option in Python
Вставка
- Опубліковано 27 сер 2024
- 💻 Get the Source Code and support the channel ❤️: www.buymeacoff...
⬇️ LEARN ON THE BEST LEARNING PLATFORMS (LINKS BELOW) 😉💪 ⬇️
💻 My Source Codes: www.buymeacoff...
☕ Buy me a coffee: www.buymeacoff...
😍 One-off donation: www.paypal.me/...
SKILLSHARE
(Python, Web Dev, UI/UX Design, Music, Art, Animation and a lot more)
🔗 skillshare.eqc... (Affiliate)
DATACAMP
(Python, ChatGPT, SQL, Power BI, and a lot more)
🔗 datacamp.pxf.i... (Affiliate)
COURSERA PYTHON
(For beginners, Data Science, Data Analysis, AI, Cybersecurity and a lot more):
🔗 imp.i384100.ne... (Affiliate)
COURSERA WEB DEVELOPMENT
(Full Stack, Front-End, Back-End, Web Design and a lot more):
🔗 imp.i384100.ne... (Affiliate)
Learn how to create a menu for your Python programs and also how to ask the user to choose among different options.
To do that we are going to use a while true loop and some user input validation.
If the video was helpful, let me know in the comments down below and also like the video so that other people can see it. Needles to say I really appreciate your support 💪❤️
📨 SUBSCRIBE so that you don't miss any new video:
www.youtube.co...
🤗 BIO PAGE (contacts, etc): solo.to/fabiom...
Create Your Bio Page (10% OFF Upgraded Plans 😉): solo.to/inv/ND...
🔗 RELATED CONTENT (videos, playlists, etc) 🔗
Validate User Inputs Video: • How to Validate User I...
Python Playlist: • 🐍 Learn Python With Fa...
🤩 AFFILIATE LINKS 🤩
Create Your Bio Page (10% OFF Upgraded Plans): solo.to/inv/ND...
🧑🏻💻 ABOUT ME 🧑🏻💻
I'm Fabio, I started programming with Python a lot of years ago and I fell in love with this world.
I started this UA-cam channel to help you during your own journey and I hope that my help can make you an amazing programmer who loves this world as I do.
Welcome on board!! 🚀
#pythonWithFabioMusanni #python #pythonforbeginners #pythontutorial #pythonprogramming #coding #programming
💻 *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: ua-cam.com/play/PLs8qUrmRvaR0IT4IwJl-LSweAdACW-yLK.html
pls give the code :(
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 😊
Thanks, you are amazing. You have done these steps more easier withou starting with while.... and include while later
Great
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 🤩💪
Very Nicely Explained The Entire Concept...... Expecting More Conceptual Videos....
Thank you for the comment! really appreciated! 😊😍
This has to be the best tutorial about menu making I've ever seen
Thank you for the comment! I'm glad you think so💪😍
Yes you have nicely explained the concept....
Thanks for all your efforts...
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
Thank you
Thank you for the comment! 😊💪
Nice video bro.
Love from india🇮🇳
Thank you! Really appreciated! 😍💪
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
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 😊
@@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
Thanks again Jules! 💪😉 ❤
See you in my other videos! Cheers 🤗
Gracias. Tu video me ayudo con mi tarea.
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
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?
not all heroes wear cape.
Thank you very much! Much appreciated! 🙏🏻 ❤️
Hello Fabio how do i fix because break isnt recognized or it is blocked by Pylance
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.
You are good ! Thanks
Thank you so much! 🤗❤️
Thank you!!!! omg
Hey! Thank you very much for the comment!😍💪
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.
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.
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!
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! 💪😉
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
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 😉 💪
Thank you for the help! I was stuck on while combos in pltw❤
Thank you for the comment and I'm glad the video was helpful! 💪🤗❤
I've got syntax error.. 'break' outside loop..
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 💪
have you publish the entire code somewhere? thanks.
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 😊😉
@@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!
Couldn't it be better if to use match/case conditions? I think it's more beautiful and professional
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 ( ua-cam.com/video/RvW1zJcd6oA/v-deo.html ) and even a video where I use it to make menus and commands ( ua-cam.com/video/hnmqxC6fxQA/v-deo.html ) ☺☺
@@FabioMusanni wow, thanks for so fast answer, I'll watch it
@@similartoothers9154 No worries! 😊 Hope the videos are helpful! 💪🤓
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.
Thank you for the follow up! I was actually going to reply that it was probably due to indentation and you confirmed it 😂😉
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
Why didn't he just do "print('
** Menu **')" instead of putting an empty print() ? Just curious
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.
Too long .... use case