Hello!
Today's question is this!
Python got drunk and the built-in functions
str()
andint()
are acting odd:str(4) ➞ 4 str("4") ➞ 4 int("4") ➞ "4" int(4) ➞ "4"
You need to create two functions to substitute
str()
andint()
. A function calledint_to_str()
that converts integers into strings and a function calledstr_to_int()
that converts strings into integers.
And this is my solved code!
str, int = int, str
def int_to_str(n):
return str(n)
def str_to_int(s):
return int(s)
First, we make two function int_to_str and str_to_int.
Inside int_to_str we return the number stringed.
Inside str_to_int we return the string numbered.
Easy!!!
Bye!!!!!!!
0 件のコメント:
コメントを投稿