| Reply | « Previous Thread | Next Thread » |
|
How do we declare an array..
if i want to use it in a for loop.. how to.. eg.. for i int range(0,6): t[i]=i it gives an error. it says t is not defined... pls help.... |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Code:
t=[] #An empty array for i in range(0,6): t.append(i) #In the end, t will be [0,1,2,3,4,5] |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
|
Quote:
i feel you want to know about syntax issues in python then please have a look at this link on my website. the website is now going through a renovation there are lots and lots syntax issues i am going to cover. Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
thanks...
for strings how do we do it.. eg a=["","",""] a[0]=["ka",karr"] a[1]=["a","b"] a[2]=["db","gh"] it works ... but it has some some shortcomings which i discovered while making an application. like u said a=[] then what should we do |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
|
Quote:
Also, here's a pretty good tutorial about Python arrays (also known as lists): http://effbot.org/zone/python-list.htm |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
|
Quote:
a = [] is a empty list and is very useful in some cases. You can add whatever content you want to add in it. like in bogdans post he has clearly adding the numbers 0 to 6 in the empty list t. Hope you got it Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
thanks..
i want the array a to be 2d array of strings. in which a[0],a[1],a[2] store a list. a stores all these . is there any other method to implement it. i want the array a to store a=["ka""kar","a""b","c"] a[0] has ka and kar and so on..
Last edited by kar2905 : 2008-10-04 at 18:01.
|
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Well you can use the append method to add items to the end of the array when needed. You can use assignment
(a[0]="something", for example) to modify elements that are already in the array according to their index. And you can use the insert method to insert items at a certain position in the array. |
|
can i append more than one string at a time using append.
eg. a.append("kartik","kar") it gives an error so how to make a[2] store both kartik and kar do you mean that I should use a.append("kartik") then use a.insert(position,"kar") |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
If you want an element of the array to be an array, simply append an array:
Code:
a.append(["kartik","kar"]) |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| SQL query Issue | kamaljaiswal | General Symbian C++ | 4 | 2008-06-25 10:17 |
| I cannot send query string to the servlet | raghda | Mobile Java Networking & Messaging & Security | 1 | 2007-09-10 08:23 |
| Dialog query!!! | Trojan | General Symbian C++ | 3 | 2006-10-13 10:36 |
| Multiline Query in 3rd edition sdk | parag_purkar | Symbian User Interface | 1 | 2006-09-26 04:54 |
| Query problem | samweb | General Symbian C++ | 2 | 2004-07-05 11:03 |