Re: [Tutor] Issue w/ while loops

2013-11-23 Thread Marc Tompkins
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

Re: [Tutor] Issue w/ while loops

2013-11-22 Thread Danny Yoo
> 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

Re: [Tutor] Issue w/ while loops

2013-11-22 Thread Rafael Knuth
>> 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

Re: [Tutor] Issue w/ while loops

2013-11-21 Thread Rafael Knuth
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

Re: [Tutor] Issue w/ while loops

2013-11-21 Thread Alan Gauld
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

Re: [Tutor] Issue w/ while loops

2013-11-21 Thread Amit Saha
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

Re: [Tutor] Issue w/ while loops

2013-11-21 Thread Dave Angel
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

Re: [Tutor] Issue w/ while loops

2013-11-21 Thread Peter Otten
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

[Tutor] Issue w/ while loops

2013-11-21 Thread Rafael Knuth
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()