Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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 28,722 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!!