Create a two-dimensional array at runtime: Difference between revisions
Create a two-dimensional array at runtime (view source)
Revision as of 12:38, 27 February 2007
, 17 years agoPython example
(-> IDL) |
(Python example) |
||
Line 58:
}
==[[Python]]==
[[Category:Python]]
'''Interpreter:''' [[Python]] 2.5
width = int(raw_input("Width of array: "))
height = int(raw_input("Height of Array: "))
array = [[0] * width for i in range(height)]
array[0][0] = 3.5
'''Note:''' Some people may instinctively try to write array as [[0] * with] * height, but the * operator creates ''n'' references to [[0] * width]
==[[IDL]]==
|