[Tutor] Help on Python

Richard Damon Richard at Damon-Family.org
Tue Oct 15 06:38:08 EDT 2019


On 10/14/19 8:07 PM, Tyson Barber wrote:
> Hello Tutor,
>
> I am new to Python and had a question.
>
> incomevar = (input("Please enter the income: ")
>             income = int(incomevar)
> costvar = int(input("Please enter the cost: ")
>             cost = int(costvar)
>                 if income >= cost :
>                   print (income - cost == profit)
>               else income < cost :
>                   print (cost - income == loss)
>
> I have tried many things for this to work, including changing the variable
> names, spacing issues. Nothing seems to work and I am quite confused. I
> honestly don't even know if this is the right email address to send this to.
>
> Thank you,
> Tyson Barber
>
What are you expecting a line like

                  print (income - cost == profit)

to do, and why?

That statement says in python, compare the value of income - cost to the
value of profit, and print True or False depending on if they are equal
or not.


Also, in python spacing is important, lines should not be randomly
indented. All the statements should be at the same indent (probably no
indent), except those controlled by the if and else statements, which
should be indented a bit more than the if and else statements.


-- 
Richard Damon



More information about the Tutor mailing list