(((Python)))
How can we use a LIST in a sequence or an IF Statement? Do we create a list, like in a Tuple, or can we ask a user for a set of items to add into our list? Give some examples if you can.
➢ In python we can create a list by putting all the elements inside a square bracket[] separated by a comma
➢ A list can have any type of data (i.e, string, float, integer)
➢ A list can also have a list inside a list
Lists with IF statement:
In the below code shopping is the list and bread, jam, and marmite are the elements of the list
creating a list inside a tuple or vice versa:
➢ we can create a list inside a tuple or a tuple inside a list in python
example:
Taking user input for creating a list:
by using the following code we can take the input of the list from the user:
Get Answers For Free
Most questions answered within 1 hours.