I wanted to try writing functions of a language to a different one. I opt for C to Python, and here is what I've done so far.
Code:
def printf(text, *args):
print(text % args, end = '')
def scanf(text, *args):
args = input(text % args)
return args
name = None
scanf("What's your name? %s", name)
printf("Hello, %s.\n", name)
Result:
What's your name? NoneBoy
Hello, Boy.
I have 3 problems regarding this question:
scanf
doesn't actually print out the variable to be inputted.- I have to implement a variable with no value, but unlike C, where you could just write
int result;
, you must write it asresult = None
and my function would printNone
as well. - It never returned any value.
Are there any solutions I can use to fix these?