How to split integer input in python?

后端 未结 3 855
走了就别回头了
走了就别回头了 2021-01-26 00:41

If you write like

n = str(input())

n = n.split()

print(n)

That will work. But if you try to do it with integers, you will get



        
3条回答
  •  迷失自我
    2021-01-26 00:47

    You can do that like this,

    n = 567
    a = str(n).split(YOUR DELIMITER)
    

    Like if YOUR DELIMITER = 6, Then if i print(a) then i get,

    ['5', '7']
    

提交回复
热议问题