Why doesn’t Python concatenate strings with other data types like Java does?
Why can’t I do:
big_int = int(big_string)?
Some languages might have a representation of
NotaNumber (NaN) which would be given if we attempt to cast a number from a string that cannot be cast. All Python can do is raise an exception.
>>> big_string = '10000000' >>> big_int = int(big_string) >>> big_int 10000000 >>> bigger_string = '1_000_000_000' >>> bigger_int = int(bigger_string) Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> bigger_int = int(bigger_string) ValueError: invalid literal for int() with base 10: '1_000_000_000' >>>