+ 21

[Challenge] for runAways: Output the return but no output of function itself

There was a post related to python: Given a function with output(print) and return. Show the return w.o outputting the print. Example def challenge(): print("dont print this") return("only print this") print(challenge() ) should output only print this. Transfer it to your language as you use a method instead of. Here is Yans Post https://www.sololearn.com/discuss/1368410/?ref=app

26th Jun 2018, 8:27 AM
Oma Falk
Oma Falk - avatar
31 Antworten
+ 12
https://code.sololearn.com/c1TIbfKOYpK2/?ref=app macros are hilarious
26th Jun 2018, 12:19 PM
hinanawi
hinanawi - avatar
28th Jun 2018, 6:20 AM
LukArToDo
LukArToDo - avatar
+ 15
1) Mods are not primarily responsible for reviewing lessons/assignments/quizzes. 2) I can totally see why this is "too far off" to be published. https://code.sololearn.com/c3S6oZy3v1tC/?ref=app
26th Jun 2018, 9:04 AM
Hatsy Rei
Hatsy Rei - avatar
+ 14
Tried to match the pattern as closely as possible: https://code.sololearn.com/cFq3TW3PEt9S/?ref=app edit: switched to puts() vs printf() + made print override a default parameter, now matches better :)
27th Jun 2018, 4:51 AM
Kirk Schafer
Kirk Schafer - avatar
2nd Jul 2018, 8:52 AM
Cépagrave
Cépagrave - avatar
+ 10
It turns out that I was blinded by trying to get ctypes to work. This is all that's required: def fn(print=tuple): print("nothing") return("something") print(fn())
27th Jun 2018, 4:57 PM
Kirk Schafer
Kirk Schafer - avatar
+ 8
I have found an easy easy python solution... a bit proud, to be honest. https://code.sololearn.com/cja32mtbJ7ne/?ref=app
27th Jun 2018, 8:29 PM
Oma Falk
Oma Falk - avatar
+ 7
Maybe like this, I kept it simple: https://code.sololearn.com/cKMEu4w43bKZ/?ref=app
26th Jun 2018, 11:25 AM
Paul
Paul - avatar
+ 6
Jokes aside, thanks for the challenge. This can actually be practical at toggling debug mode for a small project, for instance.
26th Jun 2018, 9:17 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
Many solutions try to manipulate the function. But regard the function as totally normal. The idea should work for ANY function that prints and returns.
27th Jun 2018, 8:14 PM
Oma Falk
Oma Falk - avatar
27th Jun 2018, 8:17 PM
Oma Falk
Oma Falk - avatar
+ 5
Dear mods (SL), It is too far away from what you like as assignment. So I did it this way.
26th Jun 2018, 8:28 AM
Oma Falk
Oma Falk - avatar
+ 5
27th Jun 2018, 8:47 AM
bedawang
bedawang - avatar
+ 5
Kirk Schafer not exactly what I wanted but special award for creativity.
27th Jun 2018, 8:15 PM
Oma Falk
Oma Falk - avatar
+ 5
Paul Caron so we can welcome JS too!
3rd Jul 2018, 2:19 PM
Oma Falk
Oma Falk - avatar
+ 4
Hatsy Rei 1. correction 2. nice solution (-; c++ is a 3liner for it.
26th Jun 2018, 9:14 AM
Oma Falk
Oma Falk - avatar
+ 4
You can also safe all not printed values. https://code.sololearn.com/cq6Fqr2iLAEZ/?ref=app
2nd Jul 2018, 10:21 AM
Sebastian Keßler
Sebastian Keßler - avatar
+ 4
When I look at the possibilities we should be very carefully when we call Modules in Phyton. They are Blackboxes and can do anything with our Data.
3rd Jul 2018, 8:14 AM
Sebastian Keßler
Sebastian Keßler - avatar
+ 4
Sebastian Keßler yes, totally easy to write a virus.
3rd Jul 2018, 8:19 AM
Oma Falk
Oma Falk - avatar
27th Jun 2018, 3:03 AM
Maron Zaiton
Maron Zaiton - avatar