+ 1
Whats wrong with this simple pythone code?
1 col=input(); 2 per=col; 3 per=per/100; 4 print(per); This simple code gives error and point 3 string Whats wrong with that?(sorry for bad English)
5 Antworten
+ 5
input defaults as string and you get a TypeError when you want to divide a string by an int data type at line 3
to avoid this you need to convert the string into an int by doing this:
col=int(input())
+ 4
Avinesh
they can be used as newliners so you can write multiple statements in one line but that just makes the code much uglier. they are literally ignored if you add them just as an ending to a statement
+ 2
I did not know that semicolons could be used in Python to terminate a statement.
+ 2
Sebastian Pacurar thanks for sharing this, I am new to Python and have missed these small details.
0
Thanks