Concatenation, User Inputs, Lists | Learn Python From Scratch 3 | Kovolff

Опубликовано: 16 Февраль 2026
на канале: kovolff
209
1

Concatenation:
When concatenating multiple elements in Python, ensure that each element is a string.
For non-strings simple use the str() function

User Inputs:
Obtain user inputs with the input() function. This function takes one parameter, namely the text you wish the user to see before inputting his value

ie: km_input = input(‘please enter km value’)

Do not forget to subsequently cast your input to the right type of variable.
In the example above if I need the user to input a number, then it would be best to convert the input to an int or float

ie: km_input = input(‘please enter km value’)
km_value = float(km_input)

Lists:
When you notice that you have a recurring type of variable, maybe it is best to use a list, to place all those values in.

ie instead of:
name_1 = ‘John’
name_2 = Frank’
name_3 = ‘Barry’

Use a list such as: names = [‘John’, ‘Frank’, ‘Barry’]

You can access each element in the list by calling the list variable along with the index of the element required. So if you need to access ‘frank’ then call names[1] - Note that list indices start with 0 not 1.

#python #lists #concatenation