A quick word on blocking ads

It looks like you are using an ad blocker. That's okay. Who doesn't? But without advertising revenue, we can't keep making this site awesome. Click the link below for instructions on disabling adblock.

How to disable ad-blocker for Newschoolers

  • Home
  • News
    • Latest
    • Top Rated
    • Features
    • Podcasts
    • Tags
    • Interviews
    • Event Coverage
    • Opinions
    • Industry News
    • Gear
  • Forums
    • Categories
    • Ski Gabber
    • Non-Ski Gabber
    • Site Discussion
    • Media & Arts
    • Gear
    • Lady Gabber
    • Content Creators
    • AT & Backcountry
    • Regionals
  • Gear
    • Gear Guide 2024-25
    • Gear Guide 2023-24
    • The Roofbox Reviews
    • Editors' Picks
    • Gear Talk
  • Buy/Sell
    • Map View
  • Photos
    • Latest
    • Top Rated
  • Videos
    • Latest
    • Top Rated
    • Ladies
  • Store
  • More
    • Terrain Parks Guide
    • Contests
    • NS Giveaway
    • Top Rated Members
  • Search
  • Login
  • Login

Login to Newschoolers

Register Lost password?

Search Newschoolers

Preview

LOADING...
  • Forums
  • Non-Ski Gabber
  • [Help] Programming in Python
  • Reply

Replying to [Help] Programming in Python

Hammyslapwagon:
I'm having trouble finding a way to count the number of occurrences in a list.  So I'm writing a program to play cards at the moment, and I'm appending the first six cards in the "deckOfCards" to the "handOfCards"   Now I want to see if I have multiple cards of the same suit in hand.  Normally I would use handOfCards.count(blablabla), but my list is made up of separate string objects so Python currently only counts the first one.  Since there are numbers and letters involved I can't change the whole list to an integer either :(

TLDR: How do I count the number of occurrences of each suit in deckOfCards. 

deckOfCards = ("2H","3H","4H","5H","6H","7H","8H","9H","10H","JH","QH","KH","AH",
                       "2S","3S","4S","5S","6S","7S","8S","9S","10S","JS","QS","KS","AS",
                       "2C","3C","4C","5C","6C","7C","8C","9C","10C","JC","QC","KC","AC",
                       "2D","3D","4D","5D","6D","7D","8D","9D","10D","JD","QD","KD","AD")

Click to expand post

Follow Us

Newsletter

Subscribe to our newsletter and stay up-to-date with the latest news from Newschoolers and our partners

Subscribe
Register Contact Advertise Privacy Policy Terms of Use
Newschoolers has affiliate partnerships so we may receive compensation for some links to products and services.
© 2025 NEWSCHOOLERS, INC.
NEWSCHOOLERS is a registered trademark of NEWSCHOOLERS, INC.
  • Bike
  • Fantasy Surfer
  • Newschoolers
  • Powder
  • Ridemonkey
  • Snowboarder
  • Surfer
  • TransWorld Skateboarding