+ 9

Using function with input again but with my defined input

So am building a code on python that i defined a function that takes user input , but now i want to use the same function only with my defined input what is the best way to do that

10th Apr 2017, 11:49 AM
Hasan Fares
Hasan Fares - avatar
11 Answers
+ 6
you mean make a new version with no input in it
10th Apr 2017, 1:12 PM
Hasan Fares
Hasan Fares - avatar
+ 6
isn't there anyway to use the same one I forget to mention that I am using another function that takes the function we are talking about as an argument only I need it with my own string.
10th Apr 2017, 1:17 PM
Hasan Fares
Hasan Fares - avatar
+ 6
command = input().split() def get_noun (noun): noun = command [2] if noun in GameObject.objects : return noun else : choose a ..... def get_char(verb) : char = command [0] #.... the same as noun def get_verb (noun): verb_word = command [1 if .....] def get_input (): get_char(get_verb(get_noun(noun))) def hit(noun) ........ def enemy_hit()
10th Apr 2017, 2:27 PM
Hasan Fares
Hasan Fares - avatar
+ 6
what am trying to do is get the enemy to hit back using the same effects of hit
10th Apr 2017, 2:28 PM
Hasan Fares
Hasan Fares - avatar
+ 6
I tried don't know why posting a code is causing an error in connection though everything else doesn't have the error don't know if its an app bug , but i'll keep u posted when it does work ,thanks for the help anyway
10th Apr 2017, 2:50 PM
Hasan Fares
Hasan Fares - avatar
10th Apr 2017, 3:03 PM
Hasan Fares
Hasan Fares - avatar
+ 6
am trying to get the enemy to hit back after input the :enemy_hit function is what am trying to define without having to write all the hit() code again p.s. I know its still too WET am just a beginner my purpose from this code is only learning
10th Apr 2017, 3:07 PM
Hasan Fares
Hasan Fares - avatar
+ 1
you could define your function with a "text" parameter (or whatever you want) and have a version that asks for user input before calling the function with your input as an argument.
10th Apr 2017, 12:09 PM
Amaras A
Amaras A - avatar
+ 1
Sorry, your code is complicated, I have a hard time understanding it... (simple is better than complex / complex is better than complicated)
10th Apr 2017, 3:27 PM
Amaras A
Amaras A - avatar
0
give some code, I'm not sure to understand what you mean
10th Apr 2017, 1:47 PM
Amaras A
Amaras A - avatar
0
Sorry, I still don't understand. And your indentation doesn't help. Maybe you could post some code in the Playground?
10th Apr 2017, 2:31 PM
Amaras A
Amaras A - avatar