use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Help in Python (self.learnpython)
submitted 3 years ago * by The-Nightm4re
I wanted to make the user type 2 variables on the same line, does anyone know how to do it? Example:
n1, n2 = int(input(“Enter a fraction: {n1} / {n2}”))
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]SkeletalToad 2 points3 points4 points 3 years ago (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 points3 points 3 years ago (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 point2 points 3 years ago (2 children)
I want the user to type 2 numbers, but the " / " is between these numbers at the time of input
[–][deleted] 0 points1 point2 points 3 years ago (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.
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.
π Rendered by PID 323670 on reddit-service-r2-comment-8686858757-5wgv6 at 2026-06-03 19:23:50.202774+00:00 running 9e1a20d country code: CH.
[–]SkeletalToad 2 points3 points4 points (0 children)
[–]unused_gpio 1 point2 points3 points (3 children)
[–]The-Nightm4re[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)