I have this string "45/9"
I want to get everything before the slash to be in int1 and get everything after the slash to be in int2.
(Please note: the numbers could grow to triple or even quadruple digits eventually)
I have this string "45/9"
I want to get everything before the slash to be in int1 and get everything after the slash to be in int2.
(Please note: the numbers could grow to triple or even quadruple digits eventually)
Just use string split
s = "45/9"
# split
[int1, int2] = s.split("/")
# convert from string to int
int1 = int(int1)
int2 = int(int2)
number = "45/9"
number1 = int(number.split('/')[0])
number2 = int(number.split('/')[1])
s = "45/9"
int1 , int2 = list(map(int, s.split("/")))
done. string split function splits the string at '/' character and returns a list. map function maps integer to each element of the returned list and returns map object. then used list constructor to create list and int1, int2 variable takes 1st and 2nd value.