173k views
5 votes
Write a program that input a number and display its precessor and successor number using function.

User Sugre
by
4.8k points

1 Answer

5 votes

Answer:

def ask():

x = int(input("Pick a number: "))

p = x - 1

s = x + 1

print("The predecessor is {} and the successor is {}.".format(p, s))

ask()

Step-by-step explanation:

"def ask():" and everything indented defines the function and "ask" calls the function.

User Noah Koch
by
4.6k points