Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Defining 'i' and the 'numbers' empty list
- i = 0
- numbers = []
- print("\n")
- # While is is less than 6, it adds the index number to the end of the 'numbers' list.
- def numbering(i, high, jump):
- while i < high:
- print(f"At the top i is {i}")
- numbers.append(i)
- i = i + jump
- print("The list 'numbers' is now: ", numbers)
- print(f"At the bottom i is {i}\n")
- print("Now we will define a list consisting of a sequence of integers")
- # Asking for variables
- def ask():
- bottom = int(input("Add the lowest element in the list: "))
- top = int(input("Add the highest element in the list: "))
- if top < bottom:
- print("\nThe highest element needs to be higher than the lowest!\n")
- ask()
- step = int(input("Add the step by which the list increments: "))
- return(bottom, top, step)
- bottom, top, step = ask()
- print("\n")
- # Running the function
- numbering(bottom, top + 1, step)
- warning = "!!! Notice how the very last number did not go into the list !!!"
- print("." * len(warning))
- print(warning)
- print("." * len(warning))
- print("\n")
- # Prints all the numbers in the 'numbers' list
- print("The numbers in the 'numbers' list are: ")
- for num in numbers:
- print(num)
- print("\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement