Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python SQLAlchemy Basics Working with SQLAlchemy Update and Delete Books

Kiefer H
Kiefer H
5,665 Points

Can we use match instead of if-else for Menu Options?

As it is coded, we have a select amount of options.

Instead of if-else, would it not be better to use match-case? And for any unforeseen inputs we can cover it with a 'case _'

Although I do understand match won't be good for universal compatibility because you need Python 3.10+ to take advantage of it. I don't see many people using match but after I learned it, it just seems like a better option for a specific amount of options?

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 27,918 Points

You are thinking ahead. Nice work!

Definitely, you can use match-case if your target is Python 3.10 and higher! Treehouse tries to teach a curriculum that is compatible with users of older (and still supported) versions of Python.

TLDR; I know of a couple of large companies that still have a large codebase of 2.7.11 not to mention certain versions of Linux that maintain 3.6.x Python in their long-term support branch.

Good luck with your Python journey!

Kiefer H
Kiefer H
5,665 Points

Almost everything Treehouse teaches is pretty much applicable in the newer versions of Python so far that I have found! Anything that's not? I have become accustomed to just ctrl-clicking the packages and reading the depreciation code as it usually shows the new way of doing it!

I use Pycharm... not sure if that works in any other IDE's :D

Treehouse + Hyperskill = me learning lots!! :D

Thanks! have a good day!!