[Tutor] User selection as both string and int

Marc Gartler gartler at express.cites.uiuc.edu
Wed Dec 15 04:50:30 CET 2004


Thanks.  That was pretty basic...

On Tuesday, December 14, 2004, at 09:18  PM, Loptr Chaote wrote:

> On Tue, 14 Dec 2004 21:13:00 -0600, Marc Gartler
> <gartler at express.cites.uiuc.edu> wrote:
>> I am trying to have a user select from amongst a list of items, and
>> then make use of that choice later on as both a string (e.g. "you 
>> chose
>> _____").  My function currently allows for a numerical choice, but I 
>> am
>> not sure how to return it as the item (e.g. apple) rather than the
>> integer corresponding to the position in the list:
>>
>
> It looks like all you need is a
>
>   print 'You selected: ', fruit_list[fruit]
>
> after the get_material() call.
> This accesses the position >fruit< (i.e. the value in fruit) in the
> array fruit_list.
> Try
>
>   print fruit_list[0], fruit_list[1], fruit_list[2]
>
> and you'll understand how it works.
>
> -L.C
>



More information about the Tutor mailing list