How do you define a function while calling for user input?? I need to solve this, I'm a beginner to Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do you define a function while calling for user input?? I need to solve this, I'm a beginner to Python

Define yell_this() and call with variable argument define variable   words_to_yell   as a string gathered from user  input() Call  yell_this()  with   words_to_yell  as argument get user input() for the string words_to_yell # [ ] define yell_this() # [ ] get user input in variable words_to_yell # [ ] call yell_this function with words_to_yell as argument I've tried various methods: ____ def yell_this(): words_to_yell = input("enter words to yell: ") yell_this(words_to_yell) ____ HELP PLEASE!!

22nd Feb 2018, 4:28 PM
Josh Redmon
Josh Redmon - avatar
2 Answers
+ 3
while calling a function with argument(actual arg) , function definition should also have argument(formal arg).so just modify your code as follows: def yell_this (words_to_yell): words_to_yell=input("enter words to yell:") print(words_to_yell) words_to_yell=1 #any default value yell_this(words_to_yell) https://code.sololearn.com/cqhvGkjkSMx1/?ref=app
22nd Feb 2018, 7:32 PM
Manorama
Manorama - avatar
0
Thanks! big help
22nd Feb 2018, 7:38 PM
Josh Redmon
Josh Redmon - avatar