How can I avoid space in a list when I use function in python3?


  • -1
    W

    when I use list.append() or list.remove()
    the list will add a space to every elements except the first one.
    for example:
    nums = [1,2,3]
    nums.append(4)
    print(nums)
    the result will be [1, 2, 3, 4] but not[1,2,3,4]


  • 0

    There are no spaces in those lists. They're only printed with spaces. For better readability. It's not a bug, it's a feature. I could tell you how to print those lists without spaces, but you really shouldn't.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.