0
Code lesson 13,comes up with 1.0 rather than the 1. I want.
I used "print(1.)" But it keeps on coming up with 1.0 eventually I tried "print (1+.) But then I just get a syntax error.anyone help
4 odpowiedzi
+ 5
If you want to print "1."
Use print(str(1) + ".")
It prints 1.0 in your first attempt because the compiler thinks you meant to make one of float type by (1.) Which is an equavalent of 1.0
But in second example you try to add '.' to 1 which is neither a string or a variable.
+ 4
Wanna print like
1.
2.
3.
..
9. , Right?
If so, Just do
print("1.\n2.\n3.\n4.\n5.\n6.\n7.\n8.\n9.\n")
or do this
print ("""1.
2.
3.
4.
5.
6.
7.
8.
9.""")
print(1+) is invalid syntax ,so it raise syntax error in your code
+ 3
Yes. this 1. will be interpreted as a double or float number data type. That's why it will be print as 1.0.
But you have to print a string. So you have to use :
print("1.")
+ 2
Thanks all of you