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, 22.06.2019 01:30
How will you cite information that is common knowledge in your research paper?
Answers: 1
question
Computers and Technology, 22.06.2019 09:30
What are the steps involved in accepting all the changes in a document? arrange these in order click edit. click accept or reject. click changes. click accept all.
Answers: 1
question
Computers and Technology, 24.06.2019 11:20
William travels a lot on business purpose. he needs to regularly communicate with his business partner. he also needs to send out weekly reports to his boss while he is traveling. which web-based application best suits william’s needs? (social media, webmail, wiki) is the best web-based application for william. he can access this application via the internet using a (digital cable, fax machine, web browser).
Answers: 1
question
Computers and Technology, 25.06.2019 20:30
David needs to create a new spreadsheet that will him determine the payroll deductions for each new employee. which function would he use when he wants the spreadsheet
Answers: 1
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
Questions on the website: 13722360