lundi 27 janvier 2014

Re: Help with my 8-year old son's first program. I'm stuck topic




First, forget about the def a() statement. def is for defining a function and this is not a function. Second, research the difference between == (logical test) and = (assignment operator). Third, take a look at the length of "op" just after the readline(). You can add a line that says

print(len(op))

right after the readline to see what's goingon. There's a new line character in there. Try using

op = op.strip()

before you do all the if statements. That will remove the trailing newline, and change the first test back to op == "d".

Hope this helps.

John

>PS: At the first statement, we've also tried


>op == "d":


>But that doesn't work either.




>On Saturday, January 25, 2014 10:02:15 AM UTC, (E-Mail Removed) wrote:
>> My son is learning Python and I know nothing about computers.
>>
>> He's written a simple calculator program that doesn't work. For the life of me, I can't see why.
>>




--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-






Aucun commentaire:

Enregistrer un commentaire