In [1]:
val = input()
In [2]:
print(val)
In [3]:
print(type(val))
In [4]:
val = input('Enter your name: ')
In [5]:
print(val)
In [6]:
print(type(val))
In [7]:
val = input('Enter number: ')
In [8]:
print(val)
In [9]:
print(type(val))
In [10]:
i = int(val)
In [11]:
print(i)
In [12]:
print(type(i))
In [13]:
f = float(val)
In [14]:
print(f)
In [15]:
print(type(f))
In [16]:
val = input('Enter number: ')
In [17]:
print(val)
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)
In [21]:
val_1 = input('Enter 1st value: ')
val_2 = input('Enter 2nd value: ')
val_3 = input('Enter 3rd value: ')
In [22]:
print(val_1)
In [23]:
print(val_2)
In [24]:
print(val_3)
In [25]:
l = []
print('Enter "over" then finish')
while True:
val = input('Enter value: ')
if val == 'over':
print('FINISH')
break
l.append(val)
In [26]:
print(l)
In [27]:
l = list(iter(input, 'over'))
In [28]:
print(l)
In [29]:
l = list(iter(lambda: input('Enter value: '), 'over'))
In [30]:
print(l)
In [31]:
s = '\n'.join(iter(input, ''))
In [32]:
print(s)
In [33]:
print(type(s))
In [34]:
val = input('Enter values separated by comma: ')
In [35]:
print(val)
In [36]:
l = val.split(',')
In [37]:
print(l)
In [38]:
print(type(l))