This is the question I am trying to answer:
- In main, generate a random integer that is greater than 5 and less than 13. print this number on its own line. - Done
- Call the makelist function with the random integer as sole argument. - This confuses me
- Make an empty list inside the makelist function. - Done
- Use a loop to append to the list a number of elements equal to the random integer argument. All new list elements must be random integers ranging from 1 to 100, inclusive. Duplicates are okay. - Not Done
- Return the list to main. - Not Done
- Back in main, catch the returned list and sort it. - Not Done
- Finally, use a for loop to display the sorted list elements, all on one line, separated by single spaces. - Not Done
This is what I have so far:
import random
def main():
number = random.randint(6, 12)
print('the number is', number)
def makelist():
numbers = random.randint(1, 100)
empty_list = []
empty_list.append(numbers)
I am having trouble trying to understand the loops/append part...could someone give me some guidance? Thanks.
makelist) that accept one argument, that argument will be the random number you generated that is between(5, 13). The definition ofmakelistshould be one of a function that accept one argument, currently yours accept no arguments.