Skip to content

Fix ValueError in Day 2 string-to-int casting example#874

Open
Navamanidhassan wants to merge 1 commit into
Asabeneh:masterfrom
Navamanidhassan:fix-day2-casting-issue-547
Open

Fix ValueError in Day 2 string-to-int casting example#874
Navamanidhassan wants to merge 1 commit into
Asabeneh:masterfrom
Navamanidhassan:fix-day2-casting-issue-547

Conversation

@Navamanidhassan

Copy link
Copy Markdown

Description

Fixes a ValueError: invalid literal for int() with base 10: '10.6' in the Day 2 data type casting examples. In Python, a string containing a float literal cannot be directly cast to an integer using int(). It must first be parsed as a float.

Changes Made

  • Updated int(num_str) to int(float(num_str)) where num_str = '10.6'.

Verification

  • Confirmed the script now executes smoothly without throwing a runtime error.

Closes #547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

02_variables_builtin_functions.md example code

1 participant