Open utterances-bot opened 3 years ago
The get_gdp()
function above throws an error, as the input values in get_gdp('1000000','500000','800000','100000','2000000')
are not of the right type (string instead of integer or float).
The +
operator has different meanings when used with numeric values or when use with strings. When use with numbers (float, integers, etc) it means addition. When use with strings it means concatenation. In this case, use integers instead of strings. aka, remove the '' from the numbers. Ex. get_gdp(1000000, 500000, 800000, 100000, 2000000)
print("finished")
Indeed here you can see how the strings are not taken as numbers that is why is throwing, the error.
@cforgaci I wanted to actually have a code cell exemplifying how the wrong input outputs an error, but perhaps this makes things more complicated. Therefore I will put it back as integers. Thanks for your patience and the question.
@jurra, that was my response to the exercise. I realised that was the intention and the error helps to illustrate the importance of using the right types, so you could keep the wrong version for comparison.
Types and built-in functions — Python essentials for GIS learners
https://the-magnificents.github.io/04-02-2021-Carpentry-for-HGIS/01_Day_1_Unix_Shell/excercises/B3_Exercise.html