On Sat, Nov 23, 2013 at 8:30 AM, Rafael Knuth wrote:
> Marc,
>
> great feedback - thank you very much!
> I will bear that in mind for the future.
>
> I modified my program as you suggested, but I received a runtime
> error; I tried to fix that but unfortunately I didn't succeed.
> The modified pro
> Ok, got you!
>
> print("TIME TRACKING")
>
> while True:
> hours_worked = input("How many hours did you work today? ")
> try:
> hours_worked = float(hours_worked)
> break
> except ValueError:
> print ("Invalid input")
> if hours_worked < 24:
> print("You mus
>> I'm only stuck at one point: How do I loop back to the beginning in
>> case the user input is invalid?
>
>
> Look at Peter's example. He set a variable to false when the input was
> wrong. You can check that value in your while loop.
Ok, got you!
print("TIME TRACKING")
while True:
hours_w
Hej there,
@David @Peter @Amit:
Thank you so much - you guys helped me understand my misconceptions
and I learned a couple new things.
On Thu, Nov 21, 2013 at 12:44 PM, Amit Saha wrote:
> On Thu, Nov 21, 2013 at 9:00 PM, Rafael Knuth wrote:
>> Hej there,
>>
>> I want to use a while loop in a pr
On 21/11/13 13:17, Rafael Knuth wrote:
I'm only stuck at one point: How do I loop back to the beginning in
case the user input is invalid?
Look at Peter's example. He set a variable to false when the input was
wrong. You can check that value in your while loop.
HTH
--
Alan G
Author of the L
On Thu, Nov 21, 2013 at 9:00 PM, Rafael Knuth wrote:
> Hej there,
>
> I want to use a while loop in a program (version used: Python 3.3.0),
> and I expect it to loop unless the user enters an integer or a
> floating-point number instead of a string.
>
> print("TIME TRACKING")
> hours_worked = inpu
On Thu, 21 Nov 2013 12:00:31 +0100, Rafael Knuth
wrote:
hours_worked = input("How many hours did you work today? ")
while hours_worked != str() or int():
hours_worked = input("Can't understand you. Please enter a
number! ")
There are two problems with your conditional expression. First
Rafael Knuth wrote:
> Hej there,
>
> I want to use a while loop in a program (version used: Python 3.3.0),
> and I expect it to loop unless the user enters an integer or a
> floating-point number instead of a string.
>
> print("TIME TRACKING")
> hours_worked = input("How many hours did you work
Hej there,
I want to use a while loop in a program (version used: Python 3.3.0),
and I expect it to loop unless the user enters an integer or a
floating-point number instead of a string.
print("TIME TRACKING")
hours_worked = input("How many hours did you work today? ")
while hours_worked != str()