Skip to content

Commit

Permalink
序列对象-扑克牌
Browse files Browse the repository at this point in the history
  • Loading branch information
CanisMinor-1037 committed Jul 25, 2024
1 parent 178049b commit fa25289
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ch02/suits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
1: 'coin', 'string', 'myriad'
2: 'coin'
3: 'coin', 'cup', 'sword', 'club'
4: 'coin', 'cup', 'spade', 'club'
5: 'heart', 'diamond', 'spade', 'club'
"""
#
chinese = ['coin', 'string', 'myriad']
suits = chinese
print(suits)

# - myriad, - string
suits.pop()
suits.remove('string')
print(suits)

# + cup, + sword, + club
suits.append('cup')
suits.extend(['sword', 'club'])
print(suits)

# sword -> spade
suits[2] = 'spade'
print(suits)

# coin -> heart, cup -> diamond
suits[0:2] = ['heart', 'diamond']
print(suits)

0 comments on commit fa25289

Please sign in to comment.