Wiggs Wiggs - 1 month ago 18
Python Question

How do you make a list inclusive?

I have homework that asks me to make a list from 1 to 52 inclusive. (for a deck of cards) I was just wondering how do you make a list inclusive?

I know how to make a list, just am not sure how to make it inclusive. I searched on here for awhile and couldn't really find anything helpful.

Answer

This will create list with [0,51] values

list_of_cards = [i for i in range(52)] 

This will create list with [1,52] values (This is what you want to use)

list_of_cards = [i for i in range(1,53)]
Comments