Hey guys,, can one divide a string with an integer and get the result as an integer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hey guys,, can one divide a string with an integer and get the result as an integer

23rd Sep 2021, 6:40 PM
JULIUS NDUNDA
6 Answers
+ 1
No.
23rd Sep 2021, 6:41 PM
Simon Sauter
Simon Sauter - avatar
+ 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
23rd Sep 2021, 6:52 PM
Pariket Thakur
Pariket Thakur - avatar
+ 1
Simon Sauter that's what i did str = "1" new = int(str) Have a look on my code
23rd Sep 2021, 6:57 PM
Pariket Thakur
Pariket Thakur - avatar
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.
23rd Sep 2021, 6:59 PM
Simon Sauter
Simon Sauter - avatar
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.
23rd Sep 2021, 7:23 PM
Per Bratthammar
Per Bratthammar - avatar
- 1
Beauty Is World no you can't. You have to convert it first.
23rd Sep 2021, 6:54 PM
Simon Sauter
Simon Sauter - avatar