[Tutor] What's going on with this code? Error message supplied.

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Mon Jul 11 09:55:51 CEST 2005


Alan G wrote:

>> Here's an error message:
>>
>>   File "D:\GC.py", line 78
>>     cal_opt = cal_menu()
>>     ^
>> SyntaxError: invalid syntax
>>
>> The relevant code:
>>
>> option = main_menu()
>> if option == 1:
>>     cal_menu()
>>         cal_opt = cal_menu()
> 
> 
> Consistent indentation is all important in Python
> Move the linees under the if statement into alignment:
> 
>   if option == 1:
>       cal_menu()
>       cal_opt = cal_menu()

Apart from the inconsistent indentation, I think you call cal_menu() one 
time too many. I'm quite sure that you need only need something like this:

if option == 1:
     cal_opt = cal_menu()


-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven



More information about the Tutor mailing list