From 7da1a55c891364e884c787620343087df4be0533 Mon Sep 17 00:00:00 2001 From: Joseph Murage <113748644+JosephMurage@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:14:20 +0300 Subject: [PATCH] Update 02_variables_builtin_functions.md Update to lines 231-235: To convert a string representing a float to an integer, we should first convert the string to a float using the float() function, and then convert the resulting float to an integer using the int() function. --- .../02_variables_builtin_functions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md b/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md index 4646285..73bd9b1 100644 --- a/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md +++ b/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md @@ -229,6 +229,8 @@ print(num_str) # '10' # str to int or float num_str = '10.6' +num_float = float(num_str) # Convert the string to a float first +num_int = int(num_float) # Then convert the float to an integer print('num_int', int(num_str)) # 10 print('num_float', float(num_str)) # 10.6