Printing lists in python without spaces

前端 未结 7 675
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 16:47

I am doing a program that changes a number in base 10 to base 7, so i did this :

num = int(raw_input(\"\"))
mod = int(0)
list = []
while num> 0:
    mod =         


        
7条回答
  •  终归单人心
    2021-01-12 17:24

    You can use join with list comprehension:

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

    Also, don't use list as a variable name since it is a built-in function.

提交回复
热议问题