Question: Q1: def allnum(strlist): i = 0 allnum_strlist = [] while i < len(strlist): curr_str = strlist[i] if curr_str.isdigit(): allnum_strlist.append(curr_str) i = i + 1 return
Q1:
def allnum(strlist): i = 0 allnum_strlist = [] while i < len(strlist): curr_str = strlist[i] if curr_str.isdigit(): allnum_strlist.append(curr_str) i = i + 1 return allnum_strlist
Q2:
def luck_tester(lucky_number, max_rolls, dice_size): # import the `randint` function from random import randint
for _draws in range(1, max_rolls + 1): # simulate the rolling of the dice, and check whether it # is the provided lucky number if randint(1, dice_size) == lucky_number: return 'Off to Mordor!'
return 'Back to the Shire!'
change Q1 to while loop and change Q2 to for loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
