0
How to make a program that will accept 20 numbers and print last 5 inputs
2 odpowiedzi
+ 3
Setup a loop that runs 20 times
Read number inside loop
If the loop run to, or more than 15th times
Print the number
+ 1
#Python
#
numbers=[int(i) for i in input("Enter numbers separated with a comma : ").split(",")]
### i used list comprehension here it will returns a list of numbers that user will enter
print(numbers[-6:])
### we are printing the last 6th numbers from the inputed numbers using list slicing [ : ]