Create a two-dimensional array at runtime: Difference between revisions

Python 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]]==
79

edits