Re: Arrays

Slie stackslip at gmail.com
Thu Nov 25 18:32:57 EST 2010


I have an exercise im working on. 
I have an array of strings, and I would like to take each peace of the array and assign it to a new array so I can iterate over each of those pieces and replace the sting I want then put it back together.

I hope that is not too confusing. This is how im trying to solve the problem.

I have a program that takes in integers and it prints out the integers in bigger ones made up of asterisks. Im supposed to alter the program so so that instead of asterisks it prints them in bigger ones made up of the number itself.

I am given arrays built to look like the numbers,  already.         

----- Reply message -----
From: "Stefan Behnel" <stefan_ml at behnel.de>
Date: Wed, Nov 24, 2010 2:18 am
Subject: Arrays
To: <python-list at python.org>

Garland Fulton, 24.11.2010 06:55:
> Is there a way I can define an Array of and unknown size so I can add and
> remove to or from it?
>
> Are arrays immutable?

Python has lists and tuples as basic data structures. Tuples are completely 
immutable, lists are completely mutable. If you want a container that has a 
fixed size but allows changing items, use a list and avoid calling 
.append() and .remove() to change items in favour of direct item 
assignments. If you want a completely mutable container, use a list and use 
it as you see fit. If you want a stack, a list will do. If you want a 
queue, a deque is a better option.

In any case, if you tell us more about what you actually want to do, we can 
give better suggestions.

Stefan

-- 
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101125/a011705b/attachment-0001.html>


More information about the Python-list mailing list