Printing an int list in a single line python3

前端 未结 10 1362
臣服心动
臣服心动 2020-12-03 01:16

I\'m new to python and I\'m trying to scan multiple numbers separated by spaces (let\'s assume \'1 2 3\' as an example) in a single line and add it to a list of int. I did i

10条回答
  •  一生所求
    2020-12-03 01:26

    For python 2.7 another trick is:

    arr = [1,2,3]
    for num in arr:
      print num,
    # will print 1 2 3
    

提交回复
热议问题