Skip to content

Modified str to int: on old_files/readme.md#793

Closed
Sananda-Dutta wants to merge 1 commit intoAsabeneh:masterfrom
Sananda-Dutta:str-to-int-problem
Closed

Modified str to int: on old_files/readme.md#793
Sananda-Dutta wants to merge 1 commit intoAsabeneh:masterfrom
Sananda-Dutta:str-to-int-problem

Conversation

@Sananda-Dutta
Copy link
Copy Markdown

fixes #792

Description what was the issue
There was a problem of str to int example Where the str with a decimal number is shown to be directly converted to int without any error, But that was a mistake.

Screenshot
image

How I solved
I converted the str to float datatype first then converting the float to int. so it doesn't cause any error.

Code

num_str = '10.6'

num_float = float(num_str)   # Convert the string to float
num_int = int(num_float)     # Convert float to integer

print('num_int', num_int)        # 10
print('num_float', num_float)    # 10.6

@Sananda-Dutta Sananda-Dutta deleted the str-to-int-problem branch March 14, 2026 06:53
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.

5

1 participant