10

I've got an array (list) that I want to check if it's size is equal to 1, if it is then it needs to append a new like as shown.

## If appended data = 1 then append the new line:
if appended_data == 1:
    appeneded_data.append("") ## Add a new line if appended data has a size of 1

Should be a fairly simple thing but I can't work it out :S

Any ideas?

Ryflex
  • 5,559
  • 25
  • 79
  • 148

1 Answers1

14

Use the len() function on it:

if len(appended_data) == 1:

Short demo:

>>> len([])
0
>>> len([1])
1
>>> len([1, 2])
2
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343