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

User Sugre
by
7.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
7.9k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.