In [1]:
val = input()


abc

In [2]:
print(val)


abc

In [3]:
print(type(val))


<class 'str'>

In [4]:
val = input('Enter your name: ')


Enter your name: Alice

In [5]:
print(val)


Alice

In [6]:
print(type(val))


<class 'str'>

In [7]:
val = input('Enter number: ')


Enter number: 100

In [8]:
print(val)


100

In [9]:
print(type(val))


<class 'str'>

In [10]:
i = int(val)

In [11]:
print(i)


100

In [12]:
print(type(i))


<class 'int'>

In [13]:
f = float(val)

In [14]:
print(f)


100.0

In [15]:
print(type(f))


<class 'float'>

In [16]:
val = input('Enter number: ')


Enter number: abc

In [17]:
print(val)


abc

In [18]:
# i = int(val)
# ValueError: invalid literal for int() with base 10: 'abc'

In [19]:
try:
    i = int(val)
except ValueError:
    i = 0

In [20]:
print(i)


0

In [21]:
val_1 = input('Enter 1st value: ')
val_2 = input('Enter 2nd value: ')
val_3 = input('Enter 3rd value: ')


Enter 1st value: x
Enter 2nd value: y
Enter 3rd value: z

In [22]:
print(val_1)


x

In [23]:
print(val_2)


y

In [24]:
print(val_3)


z

In [25]:
l = []

print('Enter "over" then finish')
while True:
    val = input('Enter value: ')
    if val == 'over':
        print('FINISH')
        break
    l.append(val)


Enter "over" then finish
Enter value: x
Enter value: y
Enter value: z
Enter value: over
FINISH

In [26]:
print(l)


['x', 'y', 'z']

In [27]:
l = list(iter(input, 'over'))


x
y
z
over

In [28]:
print(l)


['x', 'y', 'z']

In [29]:
l = list(iter(lambda: input('Enter value: '), 'over'))


Enter value: x
Enter value: y
Enter value: z
Enter value: over

In [30]:
print(l)


['x', 'y', 'z']

In [31]:
s = '\n'.join(iter(input, ''))


line1
line2
line3


In [32]:
print(s)


line1
line2
line3

In [33]:
print(type(s))


<class 'str'>

In [34]:
val = input('Enter values separated by comma: ')


Enter values separated by comma: x,y,z

In [35]:
print(val)


x,y,z

In [36]:
l = val.split(',')

In [37]:
print(l)


['x', 'y', 'z']

In [38]:
print(type(l))


<class 'list'>