@Axyz02
On Day 2 there in the second example in datatypes, there's an error
# int to float
num_int = 10
print('num_int',num_int) # 10
num_float = float(num_int)
print('num_float:', num_float) # 10.0
# float to int
gravity = 9.81
print(int(gravity)) # 9
# int to str
num_int = 10
print(num_int) # 10
num_str = str(num_int)
print(num_str) # '10'
# str to int or float
num_str = '10.6'
print('num_int', int(num_str)) # 10
print('num_float', float(num_str)) # 10.6
# str to list
first_name = 'Asabeneh'
print(first_name) # 'Asabeneh'
first_name_to_list = list(first_name)
print(first_name_to_list) # ['A', 's', 'a', 'b', 'e', 'n', 'e', 'h']
You will get the following output:
""""num_int 10
num_float: 10.0
9
10
10
Traceback (most recent call last):
File "main.py", line 19, in <module>
print('num_int', int(num_str)) # 10
ValueError: invalid literal for int() with base 10: '10.6'"""
This line is returning the error: print('num_int', int(num_str)) # 10
Float needs to be added to get rid of the error: print('num_int', int(float(num_str))) # float() is added
8 апреля 2023
happy weekend,
Get free signals and basic tips to enhance your Analysis here:
t.me/securedforexcryptotrade
Those who want to start earning in the digital economy here in telegram for FREE using their phones should check her out:
@catia_frndz
1.4K ·