0
Hey guys,, can one divide a string with an integer and get the result as an integer
6 Antworten
+ 1
No.
+ 1
JULIUS NDUNDA No but
u can if it is a number
For example:
str = "1" #use int() to convert
str =" k" #error
Have a look
https://code.sololearn.com/cSaxEWQvF9JJ/?ref=app
+ 1
Simon Sauter that's what i did
str = "1"
new = int(str)
Have a look on my code
0
Beauty Is World the question is if you can divide a string by a number and you can't. Your answer starts with "yes". Which is wrong.
0
Hi! There are several string operators in Python like * + \ == etc, but there is no one for / .
* is used between an integer and a string and is used to create a repetition of the string. Use built-in help() in Python to learn more about strings.
There are a possibilities to create your own classes, where you can add operators and decide how you want them to act on your objects.
- 1
Beauty Is World no you can't. You have to convert it first.