Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Int's in input please help me

Hello I googled it and could not find an answer to this

I have to take input from the user then the operator has to print what number is before the input and after the input like:

input= 3
has to print 2 and 4

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

please help

I used range did I do it wrong I am just a beginner in python please help!!!

number=int(input)

for num in range(number ,+ 1, -1):
    print(num)

>Solution :

You first need to use input() to let the user register a number.

Then, simply print the number with number - 1 and number + 1.

number = int(input("What is your number? "))
print(f"{number - 1} {number + 1}")

Outputs to:

What is your number? 3
2 4
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading