How can I put an input() statement inside a function that will be called only when the said function is also called. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I put an input() statement inside a function that will be called only when the said function is also called.

Python

8th Feb 2022, 9:48 PM
David Boateng
6 Answers
+ 1
An example if you have function called gretting with one parameter def gretting(name): print("Hello", name) gretting (input ())
8th Feb 2022, 10:02 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 1
David Boateng An example if you have function called gretting with two parameters def gretting(name,age): print("Hello", name,"your age is", age) gretting (input (), input ())
9th Feb 2022, 8:27 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 1
You're welcome
10th Feb 2022, 11:09 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
0
Awesome thanks
9th Feb 2022, 7:55 AM
David Boateng
0
Buh please what if you want to add two input statements where you will need to rep both with a variable which is only called after the function is called?
9th Feb 2022, 7:58 AM
David Boateng
0
Cool. Thanks
10th Feb 2022, 9:57 AM
David Boateng