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
I used range, did I do it wrong? I am just a beginner in Python.
number=int(input)
for num in range(number ,+ 1, -1):
print(num)
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