Why isint this working? Help me pls :c | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why isint this working? Help me pls :c

Im trying to put in this value in python: dollar = 1.000.000 ^ SyntaxError: invalid syntax It is accepting the first dot but not the second dot, why?

1st Mar 2021, 1:22 AM
Odnantiev
Odnantiev - avatar
4 Answers
+ 4
To separate sections of your literal number like this you can use the _ underscore So, for instance, 1 million can be represented like; mil = 1_000_000 print(mil) # 1000000 The use of a . (dot, period, decimal) signifies that the number is a floating point value and only 1 dot may be used in its literal representation.
1st Mar 2021, 1:45 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
Odnantiev because Python thinks dots signify floats! For integers, don't use dots! Just use 1000000 :) Also, if you use 1.000 Python will think you mean 1! Hope it helps! Happy programming :)
1st Mar 2021, 1:35 AM
TheCoder
+ 2
ChaoticDawg i see, thank you!
1st Mar 2021, 1:53 AM
Odnantiev
Odnantiev - avatar
+ 1
TheCoder thank you !
1st Mar 2021, 1:43 AM
Odnantiev
Odnantiev - avatar