[Tutor] problem with code

Timo timomlists at gmail.com
Fri Aug 21 12:39:24 CEST 2015


Op 20-08-15 om 16:49 schreef Aravind Jaya:
> time = input("How long on average do you spend on the computer per day?")
> if time <= 2:
>      print "Message1"
> else:
>      print "Message2"
>
This will raise 2 errors:
   - time will be a string. So time <= 2 is invalid.
   - print is a function.

Updated code:

time = int(input("How long on average do you spend on the computer per day?"))
if time <= 2:
     print("Message1")
else:
     print("Message2")


Also the question is ambiguous. There is no time unit. What is "long"?

Timo

>
>
> On Thu, Aug 20, 2015 at 3:20 PM, Nathan Clark <261100nc at gmail.com> wrote:
>
>> I have written a basic program out of python and it is not functioning,
>> please could you proof read my code and tell me how to fix it.It is in
>> python 3.3
>>
>> time=int(input("How long on average do you spend on the computer per day?")
>> (print("that seems reasonable")) if time<=2
>> else print ("get a life")
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list