pymi.vn Enum example

Run Settings
LanguagePython
Language Version
Run Command
import random from typing import List, Tuple from enum import IntEnum, auto class Suit(IntEnum): SPADE = auto() CLUB = auto() DIAMOND = auto() HEART = auto() for s in Suit: print(s, s.name, s.value) assert Suit.SPADE < Suit.HEART def create_cards() -> List[Tuple[int, Suit]]: return [(i, s) for i in range(1, 13) for s in Suit] def play_1_cay(n: int, s: Suit): r = random.choice(create_cards()) print("LeMe: {} vs Nó: {}: tôi win? {}".format((n, s), r, (n, s) >= r)) play_1_cay(8, Suit.CLUB)
Editor Settings
Theme
Key bindings
Full width
Lines