subject

I am new to programming, and I have made this function using Python that prompts the user to enter two numbers; the output will be read the starting number counting up to the last number. I have got this much done, but I would also like it to count down if the starting number is larger than the previous number. So, for example, if the numbers entered are 2 and 8, the output will be 2 3 4 5 6 7 8. If the user enters the opposite, 8 to start and 2 for last, the output should be 8 7 6 5 4 3 2. I have tried using if statements, but I have not been successful; I can only seem to get the function to count up never down. def main():
start = int(input( "Start? "))
last = int(input( "End? " ))
x = 0

for x in range(start, last + 1):
print(x, end = " ")

main()

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
question
Computers and Technology, 23.06.2019 22:20
If i uninstall nba 2k 19 from my ps4 will my career be gone forever?
Answers: 2
question
Computers and Technology, 24.06.2019 07:00
Why would a business likely use a java applet - to back up their data files for the business - to create a program that a customer can launch in their web browser - to create music on a powerpoint presentation - to organize files on their company directory
Answers: 3
You know the right answer?
I am new to programming, and I have made this function using Python that prompts the user to enter t...
Questions
question
Engineering, 05.02.2021 04:10
question
Engineering, 05.02.2021 04:20
question
Chemistry, 05.02.2021 04:20
question
Biology, 05.02.2021 04:20
question
Mathematics, 05.02.2021 04:20
Questions on the website: 13722359