"Rance Hall" <ran...@gmail.com> wrote
Here is what I've got so far:
l = []
for i in range(0,10)
l.append(i)
for i in range(0,10)
print('%s. %s' % (i, l[i])
I tried changing the append to l.append(i+1)
which almost worked but the output started with 1. 2 I was curious
what happend to the 0. 1 line
You made a mistake somewhere, it works as you expected
if you only make that one change.
I know generally that we aren't supposed to care about the indexes
but
this is eventually going to be part of a menuing system that
displays
the index, so I do have a legit need to care about what is happening
to the list index.
That's probably a bad idea. It's confusing for users if the number of
their
favourite command changes, as it would if you added a new command
into the list etc. (One of the big advantages of menu driven CLIs is
that
users learn the sequences they use regularly and start to "type ahead"
which makes for a very efficient operation.) It's usually better to
keep
the command number as part of the menu data and then sort the
command in order based on that.
Just a thought,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor