Dustan wrote:
Dennis Lee Bieber wrote:
for i in range(0,len(param)):
print a[i],
for it in param:
print it,
That's one way. However, if you need the position (this is for future
reference; you don't need the position number here):
for i in range(len(param)+1):
print a[i],
Hi,
I have a small problem with my function: printList. I use print with a
',' . Somehow the last digit of the last number isn't printed. I wonder
why.
import random
def createRandomList(param):
length = param
a = []
creating random list
for i in range(0,length):
why don't you iterate over the list instead of indices?
for elem in L: print elem,
you don't need the 0 when you call range: range(0, n) == range(n)
the last element of a range is n-1: range(n)[-1] == n-1
you don't need while to iterate backwards. the third argument to range
is step.
range(n-1,
I have a small problem with my function: printList. I use print with a
',' . Somehow the last digit of the last number isn't printed. I wonder
why.
Posting actual code might help...the code you sent has a horrible
mix of tabs and spaces. You've also got some craziness in your
creating
Dennis Lee Bieber wrote:
for i in range(0,len(param)):
print a[i],
for it in param:
print it,
That's one way. However, if you need the position (this is for future
reference; you don't need the position number here):
for i in range(len(param)+1):
print