newbie seeks advise.
Erik Max Francis
max at alcyone.com
Fri Sep 20 01:48:13 EDT 2002
akirasugiura wrote:
> I've been learning python for about a month. I had no prior knowledge
> of programming.
>
> My question is, I have a tuple which is, data = (69, 40, 74, 41, 56,
> 57, 38, 58, 26, 55). How I can make a function that picks up a largest
> number
> from this "data" tuple. If "data" was a 'List' I would be able to
> use "sort" but since sort doesn't work with tuple. I am stuck here.
You could always convert the tuple to a list with the list function:
data = (69, 40, 74, 41, 56, 57, 38, 58, 26, 55)
dataAsList = list(data)
and then do what you intended. Note that there is a max function which
already exhibits this behavior (which will work on any sequence):
largest = max(data)
You could always do it manually; walk through the sequence, and keep a
tally of the largest one you've seen so far.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Man is preceded by forest, followed by desert.
\__/ (graffiti written during French student revolt)
Bosskey.net / http://www.bosskey.net/
A personal guide to online multiplayer first person shooters.
More information about the Python-list
mailing list