0
Resolve a quoted variable in a function
z=100 def prnt(x): print('x= :'+str(x)) prnt(z) I wrote the above code whose output is x= :720 But instead of x= :720, I want print z= :720. How to resolve x inside a quote?
5 ответов
+ 1
you should change 'x= :' in 'z= :"
if you want be able to change the letter just add another parameter to the function in which is specified the variable's name
+ 1
and in the variable "z_name" you can put every name u want
https://code.sololearn.com/c8yij0ulJj3z/?ref=app
0
sorry, but can u give me an example? even if u put two parameters, the one inside the quote remains same, I guess.
0
Great. Thanks. just curious, is there any way to resolve sth within quote? I used SAS till now. there u can resolve a macro, if it is kept within double quote. Like, %let z=h; %put "&z"; will give u - h, whereas %put '&z' will give u - &z.
0
i don't know if there is any method, i'm not a professional programmer, i think you should ask to someone more capable than me, sorry :(