Startup Data scientist Blog

データ分析系のテック情報を発信します

pythonを使ったforループ構造

 

suits = ["Hearts","Spades","Clubs","Diamonds"]
numbers = ["2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"]

for suit in suits:
    for number in numbers:
        print(suit+" of "+number)

 

Output

Hearts of 2
Hearts of 3
Hearts of 4
Hearts of 5
Hearts of 6
Hearts of 7
Hearts of 8
Hearts of 9
Hearts of 10
Hearts of Jack
Hearts of Queen
Hearts of King
Hearts of Ace
Spades of 2
Spades of 3
Spades of 4
Spades of 5
Spades of 6
Spades of 7
Spades of 8
Spades of 9
Spades of 10
Spades of Jack
Spades of Queen
Spades of King
Spades of Ace
Clubs of 2
Clubs of 3
Clubs of 4
Clubs of 5
Clubs of 6
Clubs of 7
Clubs of 8
Clubs of 9
Clubs of 10
Clubs of Jack
Clubs of Queen
Clubs of King
Clubs of Ace
Diamonds of 2
Diamonds of 3
Diamonds of 4
Diamonds of 5
Diamonds of 6
Diamonds of 7
Diamonds of 8
Diamonds of 9
Diamonds of 10
Diamonds of Jack
Diamonds of Queen
Diamonds of King
Diamonds of Ace