'TypeError: str object cannot be interpreted as an integer [duplicate]

My code is

#import random intger
import itertools, random
#as how many cards you want delt
deck=input('Enter how many cards you want delt.')
#imports the list of the card symbol
card=list(itertools.product(range(1,14), ["Spade", "Heart", "Diamond", "Club"]))
#Picks a random card number.
random.shuffle(card)
print("You drew these cards:")
for i in range(deck):
  print(card[i][0], "of", card[i][1])
print("")
print("11s are jacks. 12s are queens. 13 are kings. 1 are aces.") 

But anytime I put in a number like 5 it breaks and says Traceback (most recent call last:) File "main.py", line 10, in for i in range(deck): TypeError: 'str' object cannot be interpreted as an integer



Solution 1:[1]

That is because the input you give is treated as a string. You can try: for i in range(int(deck)): to make sure the input is treated as a integer.

Solution 2:[2]

deck=int(input('Enter how many cards you want delt.')). Input is always str cast it to number if you are entering numbers

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JarroVGIT
Solution 2 crackaf