To generate a random t-shirt size from XS to XL in Python, you can use the random.choice()
function from the random
library to randomly select a size from a list or tuple of available sizes.
Here's an example code snippet that generates a random t-shirt size:
main.py206 chars7 lines
In the above code, we first define a list of available sizes. Then, we use the random.choice()
function to randomly select a size from this list. Finally, we print the randomly selected size using an f-string.
You can modify the sizes
list to include any additional sizes you may need.
gistlibby LogSnag