Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix currency input validation in 10_currency.py #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Ishan-Karpe wants to merge 1 commit into codedex-io:main
base: main
Choose a base branch
Loading
from Ishan-Karpe:main

Conversation

@Ishan-Karpe
Copy link

@Ishan-Karpe Ishan-Karpe commented Aug 11, 2025

Summary

Fixed the currency converter to properly handle decimal values by changing int(input()) to float(input()) for all three currency inputs (pesos, soles, reais).

Problem

The original code used int(input()) which truncates decimal places, causing incorrect calculations when users input currency amounts with cents (e.g., 10.50 would become 10).

Solution

  • Changed all three int(input()) calls to float(input())
  • Tested with decimal values to ensure correct calculation
  • Verified the fix works properly with sample inputs

Test Results

Tested with inputs: 100.50 pesos, 200.75 soles, 150.25 reais
Expected result: 87.787625
Actual result: 87.787625 ✅

Fixes #127

Changed int(input()) to float(input()) for all currency inputs to properly handle decimal values. Currency amounts can have fractional values (e.g., 10.50), so using float() instead of int() prevents data loss from truncation.
Fixes codedex-io#127 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

issue with python-101/2-variables /10_currency.py answer

1 participant

AltStyle によって変換されたページ (->オリジナル) /