Skip to content

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ishan-Karpe
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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