Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Help needed for an Array? Use Cases
-
I wish to create a blank array of 100 elements
Where blank is either Integer 0 or Empty string ‘“” (two different use cases)
Then I wish to write to specific elements in the array
Either replacing the elements or adding/appending to them
Having read and re read the documentsI have not been able fathom how to accomplish these tasks.
I recall in Algol that this was a trivial task, it was how I ”cheated” doing a sort task,
According to my professor in doing a sort. He wanted a bubble sort.
I simply wrote the numbers into an array where n= array element, and then read them outHow!? In Python?
Is a command missing from the documentation?
-
a =[0]*100 print(a)
-
sorted() is your friend... https://docs.python.org/3/howto/sorting.html
-
OMG why did I try a read the manual, I found a part in the manual that showed me that *100 would not work!?
And yet it all did!
a=[0]*100 print(a) a[10]=1 print(a) a[10]=a[10]+1 print(a) b=['']*100 print(b) b[10]='test' print(b) b[10]=b[10]+'again' print(b)
Btw I wasn’t trying to do a sort that was just a historical side comment, but thanks for the pointer, stored for future reference.
Adrius42
-
This post is deleted!