Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Int error on line 70
#1
import time
import os
import sys
import colorama
from colorama import Fore, Back, Style

cm = input(Fore.GREEN + "please enter your current usage for main: "+ Fore.WHITE)
time.sleep(0.5)
os.system("clear")
cma = input(Fore.GREEN + "please enter your current usage for marina: "+ Fore.WHITE)
time.sleep(0.5)
os.system("clear")
ca = input(Fore.GREEN + "please enter your current usage for annette: "+ Fore.WHITE)
time.sleep(0.5)
os.system("clear")
pm = input(Fore.GREEN + "please enter the previous usage for main: "+ Fore.WHITE)
time.sleep(0.5)
os.system("clear")
pma = input(Fore.GREEN + "please enter the previous usage for marina: "+ Fore.WHITE)
time.sleep(0.5)
os.system("clear")
pa = input(Fore.GREEN + "please enter the previous usage for annetta: "+ Fore.WHITE)
time.sleep(0.5)
os.system("clear")
cm = int(cm)
pm = int(pm)
cma = int(cma)
pma = int(pma)
ca = int(ca)
pa = int(pa)
mu = cm - pm
mau = cma - pma
au = ca - pa
su1 = mau + au
su2 = mu - su1
mu = str(mu)
mau = str(mau)
au = str(au)
su2 = str(su2)
print(Fore.GREEN + "your usage for main is " + mu)
print(Fore.GREEN + "your usage for marina is " + mau)
print(Fore.GREEN + "your usage for annette is " + au)
print(Fore.GREEN + "your usage for the shop is " + su2)
time.sleep(5)
os.system("clear")
print(Fore.GREEN + "now calulating the Percentage's")
time.sleep(3)
os.system("clear")
mau = int(mau)
mu = int(mu)
au = int(au)
su2 = int(su2)
maper = mau / mu
aper = au / mu
sper = su2 / mu 
maper = str(maper)
aper = str(aper)
sper = str(sper)
print(Fore.GREEN + "marina's percentage of use is " + maper)
print(Fore.GREEN + "annetta's percentage of use is " + aper)
print(Fore.GREEN + "the shop's percentage of use is " + sper)
time.sleep(5)
os.system("clear")
bill = input(Fore.GREEN + "please enter the total cost of your bill" + Fore.WHITE)
time.sleep(3)
os.system("clear")
print(Fore.GREEN + "now calculating the amount due for each person: ")
time.sleep(3)
os.system("clear")
bill = int(bill)
maper = int(maper)
aper = int(aper)
sper = int(sper)
madue = maper * bill
adue = aper * bill
sdue = sper * bill
madue = str(madue)
adue = str(adue)
sdue = str(sdue)
print(Fore.GREEN + "Marina need to pay " + madue)
print(Fore.GREEN + "annette need to pay " + adue)
print(Fore.GREEN + "the shop needs to pay " + sdue)
SO i am making a program for my grampa that calculates his energy bill for him and i am having a problem converting a the bill cost from a str to a int on line 70 it keeps giving me a value error and i cant fix it the number i have been using to test the bill cost is 157.54 if that has anything to do with it so can any of you please help
~~ UwU
Reply
#2
Right before line 70 print(bill) and print(type(bill)). That may give a clue. Looks like that line should not give an error.
Reply
#3
If you want to be able to enter 157.54 you need to convert to a float instead of an int
bill = float(bill)
Reply
#4
Don't repeat yourself (DRY)

Think how you can change your code, to remove repeating code. Hint: loops, data structures. You may also break your code into small reusable chunks - functions
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,392 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,321 Jun-18-2022, 01:09 PM
Last Post: snippsat
  Line 42 syntax error..Help!!1 patpython 4 2,608 Sep-01-2021, 03:22 PM
Last Post: deanhystad
  pandas.errors.ParserError: Error tokenizing data. C error: Expected 9 fields in line Anldra12 9 15,087 Jun-15-2021, 08:16 AM
Last Post: Anldra12
  Syntax error on line 29 manwithjeans 3 2,771 Feb-27-2021, 08:28 AM
Last Post: perfringo
  Line charts error "'isnan' not supported for the input types," issac_n 1 2,368 Jul-22-2020, 04:34 PM
Last Post: issac_n
  Pyinstaller create this error :“File ”multiprocessing\connection.py“, line 691 Formationgrowthhacking 2 3,573 Apr-30-2020, 10:26 AM
Last Post: buran
  EOFError: EOF when reading a line - Runtime Error RavCOder 6 9,556 Sep-27-2019, 12:22 PM
Last Post: RavCOder
  Error :unable to detect undefined names created in spyder ide error at line 2 milind_eac 2 8,204 Jul-30-2019, 10:29 PM
Last Post: milind_eac
  Why do i have invalid syntax on a line after print, i see no error ? iofhua 5 2,876 May-24-2019, 05:42 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020