Printing lists in python without spaces -


i doing program changes number in base 10 base 7, did :

num = int(raw_input("")) mod = int(0) list = [] while num> 0:     mod = num%7     num = num/7     list.append(mod) list.reverse() in range (0,len(list)):     print list[i], 

but if number 210 prints 4 2 0 how rid of spaces

you can use join list comprehension:

>>> l=range(5) >>> print l [0, 1, 2, 3, 4] >>> ''.join(str(i) in l) '01234' 

also, don't use list variable name since built-in function.


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -