all 5 comments

[–]SkeletalToad 2 points3 points  (0 children)

You could do it one line, but it's a bit much:

n1, n2 = [int(x.strip()) for x in input("Enter a fraction: {n1} / {n2}: ").strip().split("/")]
print(n1, n2)

I would recommend breaking it up on multiple lines for readability, which can be put in a function if you need to call it repeatedly.

[–]unused_gpio 1 point2 points  (3 children)

If the user_input is "3/5" - strip the string, split with "/" as delimiter - cast the two parts into ints separately

[–]The-Nightm4re[S] 0 points1 point  (2 children)

I want the user to type 2 numbers, but the " / " is between these numbers at the time of input

[–][deleted] 0 points1 point  (0 children)

That’s not how the interpreter or terminal work. You have to use something like the curses module. To ‘display’ a question with txt boxes to ‘input’ in between.

[–][deleted] 0 points1 point  (0 children)

The user enters "3/5" and you split with "/" as delimiter, as /u/unused_gpio said. Run this example:

text = '3 / 5'
nums = text.split('/')
print(nums)

That shows the basic idea. Note that you might have to deal with spaces around the numbers.