Looping:
def matrix(rownumber,columnumber):
matrix = []
for i in range(rownumber):
a = [0]*columnumber
matrix.append(a)
return matrix
List comprehensions:
def matrix(rownumber, columnumber):
return [[0]*columnumber for x in range(rownumber)]
Code can be music. Programming can be fun. Read about the experiences of a novice computer scientist and programmer.
def matrix(rownumber,columnumber):
matrix = []
for i in range(rownumber):
a = [0]*columnumber
matrix.append(a)
return matrix
def matrix(rownumber, columnumber):
return [[0]*columnumber for x in range(rownumber)]
No comments:
Post a Comment
Please, be polite and constructive.