Automation, Orchestration, and Scripting
A script reads the line line = 'root:x:0:0:root:/root:/bin/bash' from /etc/passwd and runs fields = line.split(':'). What is the data type of fields?
Show the answer
Correct answerC. List
The split() method breaks a string at each delimiter and returns an ordered list of strings. String is tempting because the input is a string, but split() returns a list whose elements, such as fields[2], are each strings.