Input in python

Python allows for user input.

That means we are able to ask the user for input.


username = input("Enter username:")

print("Username is: " + username)


The split() method splits a string into a list.

You can specify the separator, default separator is any whitespace.

string.split(separator, maxsplit)

txt = "apple#banana#cherry#orange"

# setting the maxsplit parameter to 1, will return a list with 2 elements!

x = txt.split("#", 1)


print(x)


PYTHON PROGRAM SYNTAX SERIES

Comments

Popular Posts