[Tutor] if statement
Joel Goldstick
joel.goldstick at gmail.com
Tue Nov 2 20:57:15 CET 2010
On Tue, Nov 2, 2010 at 3:34 PM, Adam Bark <adam.jtm30 at gmail.com> wrote:
> On 02/11/10 19:07, Glen Clark wrote:
>
>> sorry:
>>
>> NumItems = int(input("How many Items: "))
>>
>>
>> Entries = []
>> for In in range(0,NumItems):
>> Entries.append("")
>>
>>
>>
>> for In in range(0,NumItems):
>> Entries[In]=str(input("Enter name " + str(In+1) + ": "))
>>
>>
>> for In in range(0,NumItems):
>> print(Entries[In])
>>
>> confirmed = int(input("Are you happy with this? (y/n): ")
>>
>> if confirmed == "y":
>> for In in range(0,NumItems):
>> print(Entries[In] + ": " + str(In))
>> change = int(input("Which item would you like to change: ")
>> Entries[change]=str(input("Please enter a nem name: ")
>> else:
>> #do nothing
>>
>> print(Entries)
>>
>>
>>
> Ok that's easier, you're missing a closing bracket at the end of the
>
>
> confirmed = int(input("Are you happy with this? (y/n): ")
>
> line.
> I think you might need at least a pass after else as well, although it
> should be fine to leave it out altogether once you've added the ')'.
>
> HTH,
> Adam.
>
> _______
>
if confirmed == "y":
for In in range(0,NumItems):
print(Entries[In] + ": " + str(In))
change = int(input("Which item would you like to change: ")
Entries[change]=str(input("Please enter a nem name: ")
> else:
> #do nothing
>
Actually, I caught two mismatched parens. In the line starting with
'change' and the following line.
Fix those first
> ________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
--
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101102/db0bcfeb/attachment.html>
More information about the Tutor
mailing list