SPLIT()

The split() method is used to divide a string into a list of substrings based on a specified delimiter. By default, split() separates a string at whitespace characters (spaces, tabs, and newlines), but a custom separator can be provided as an argument to split the string on specific characters or substrings. An optional second argument allows you to limit the number of splits performed. The method does not modify the original string, as strings in Python are immutable; instead, it returns a new list containing the resulting substrings. split() is commonly used in tasks such as parsing input data, processing text files, tokenizing sentences, or extracting information from structured strings, making it a versatile tool for text manipulation in Python.

STRING INPUT

#!/usr/bin/env python3

def main() -> None:
    input1, input2, input3, input4 = input().split();
    print(input4, input3, input2, input1);

if __name__ == "__main__":
    main();

Last updated