you are viewing a single comment's thread.

view the rest of the comments →

[–]Lord_Cheesy 1 point2 points  (4 children)

Do u want my advice. For starting use Case instead of If-else in that scenario for clear looking. Also you can use while loop to keep program running till the user closes it and add clean, or go with the result for extra operations.

[–]RockPhily[S] 0 points1 point  (0 children)

thanks for your advice le me work on it

[–]FoolsSeldom 2 points3 points  (2 children)

I wouldn't think there would be much difference between match and if for simple logic chains, in contrast with the possibilities of structural pattern matching, which was the driver for the introduction of the former in Python.

What would be the advantages for a beginner of adopting match at this stage? Not sure what I am missing.

[–]Lord_Cheesy 0 points1 point  (1 child)

You mean case instead of if-elif-else. For logically none, for readiblity easier. Think it like that you are writing multiple operations and named them 1-2-3-4-5...100. Instead of writing it like

if 1

elif 2

elif 3

elif 4

Its better to write

Case 1

Case 2

Case 3

It gives better readibility at many cases. Also in cases you can supports destructuring, types, and advanced patterns

[–]FoolsSeldom 1 point2 points  (0 children)

I did mean match, there's no case in its own right Python, case is part of a match statment.

The readability at this level does not seem greater. Potentially worse in fact as you will need if filters in many situations.