And in the case of python
?
I can convert the string '1'
str to 1
int .
Example:
1 + int('1') # Imprime: 2
However, if I try to convert '1 cachorro'
str to int ...
int('1 cachorro');
... an error is generated:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1 cachorro'
Would it be possible to make expressions like 1 + int('1 cachorro')
work in python
?
If I needed to do this (I think I'll never need it), how could I handle this?