Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    1
    ReputationRep:
    Can anyone tell me???
    what's the similar function as select case in python ? Provide me an example if you know.
    Offline

    3
    ReputationRep:
    (Original post by amishgurung4)
    Can anyone tell me???
    what's the similar function as select case in python ? Provide me an example if you know.
    I'm not sure what you mean by 'similar function', do you mean the == operator?
    • Thread Starter
    Offline

    1
    ReputationRep:
    (Original post by lllllllllll)
    I'm not sure what you mean by 'similar function', do you mean the == operator?
    I mean to say a code or codes in python that does similar work as select-case
    Offline

    1
    ReputationRep:
    Check this link out:
    http://www.pydanny.com/why-doesnt-py...itch-case.html
    That is as good as it gets in python I am afraid.
    Offline

    20
    ReputationRep:
    (Original post by amishgurung4)
    I mean to say a code or codes in python that does similar work as select-case
    By select-case do you mean a switch statement? If so there's no analogue in python but there are ways to do it.
    A series of if, elif and else statements will have the same effect.
    Offline

    1
    ReputationRep:
    (Original post by morgan8002)
    By select-case do you mean a switch statement? If so there's no analogue in python but there are ways to do it.
    A series of if, elif and else statements will have the same effect.
    Yes. Select-case and switch statements are same. In python, you can use dictionary mapping or a series of if and elif statements as you have mentioned. For dictionary mapping, check out the link above.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    What's your favourite Christmas sweets?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.