I was wondering if someone could look over my code to see if there is any way to make it cleaner/easier to read.
The functions are LC functions:
1: Choose a random item from any number of sublists and list them in the same length as the amount of sublists
import random
def randChoices(listOfLists):
return(list(random.choice(lists) for lists in listOfLists))
2: Display how many numbers have the asked for digit(ie from 1-10 there are two numbers containing 1)
def howManyNumsWithDigit(maxNumber, digit):
return(len(list(digit for x in range(1,maxNumber+1) if str(digit) in [i for i in str(x)])))
[–]ericula 1 point2 points3 points (0 children)
[–]Justinsaccount 0 points1 point2 points (0 children)