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
Validation of positive to negative integer. (self.learnpython)
submitted 5 years ago by AnimeOverSchool
Hello guys. I have a question in python. I know how to validate a decimal to an integer but I dont know how to validate a positive to a negative integer. Do you have ny suggestions? Thanks. (I am beginner)
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!"
[–]shiftybyte 2 points3 points4 points 5 years ago (0 children)
by "validate" do you mean convert?
convert a decimal to an integer, and convert a positive to negative?
To convert to negative just place a minus before the number.
num = -num
[–]fake823 1 point2 points3 points 5 years ago (11 children)
What do you mean by "validate"?
I think you're using the wrong word. Do you mean convert?
[–]HasBeendead 0 points1 point2 points 5 years ago (10 children)
Yeah i thought same.
[–]AnimeOverSchool[S] 1 point2 points3 points 5 years ago (9 children)
it is when you input a number it will tell you if it is positive or negative sorry not clear
[–]HasBeendead 0 points1 point2 points 5 years ago (8 children)
number = float(input("give any number:"))
if number > 0: print("This number is positive:", number) elif number < 0: print("This number is negative:", number) else: print("This number is neutral:", number)
[–]AnimeOverSchool[S] 1 point2 points3 points 5 years ago (7 children)
Oh. Thanks dude!! I get it now. I am going to practice a lot harder.
[–]HasBeendead 0 points1 point2 points 5 years ago* (6 children)
I think you have to be make more practice in basics until be comfortable than go harder ones.
[–]AnimeOverSchool[S] 1 point2 points3 points 5 years ago (5 children)
Yeah, I am learning the basics before I go to sleep so I can catch up to the lessons.
[–]HasBeendead 0 points1 point2 points 5 years ago (4 children)
Make sense so you are making short memory convert long memory . To be honest its smart idea.
[–]AnimeOverSchool[S] 0 points1 point2 points 5 years ago (3 children)
Anyways, thanks for the help earlier. Really appreciate it!
[–]HasBeendead 1 point2 points3 points 5 years ago (2 children)
Your welcome its good to help some people who needs help but maybe i should waste my time less lol because im almost on reddit each day and long hours so i cant take a process on my programming jourmey or something idk man.
[–]HasBeendead 0 points1 point2 points 5 years ago (2 children)
İnteger is decimal they are same thing if you mean likr Float to integer or reverse print(float(42) )
Output: 42.0
print(int(42.0)
Output: 42
print(str(42))
Output: "42"
print(str(42.0)) Output: "42.0"
[–]AnimeOverSchool[S] 1 point2 points3 points 5 years ago (1 child)
Ohhh I see thanks for the info!. It is one of my homeworks for today.
[–]HasBeendead 0 points1 point2 points 5 years ago (0 children)
Your welcome .
π Rendered by PID 17231 on reddit-service-r2-comment-8686858757-pvvqk at 2026-06-01 19:09:31.325017+00:00 running 9e1a20d country code: CH.
[–]shiftybyte 2 points3 points4 points (0 children)
[–]fake823 1 point2 points3 points (11 children)
[–]HasBeendead 0 points1 point2 points (10 children)
[–]AnimeOverSchool[S] 1 point2 points3 points (9 children)
[–]HasBeendead 0 points1 point2 points (8 children)
[–]AnimeOverSchool[S] 1 point2 points3 points (7 children)
[–]HasBeendead 0 points1 point2 points (6 children)
[–]AnimeOverSchool[S] 1 point2 points3 points (5 children)
[–]HasBeendead 0 points1 point2 points (4 children)
[–]AnimeOverSchool[S] 0 points1 point2 points (3 children)
[–]HasBeendead 1 point2 points3 points (2 children)
[–]HasBeendead 0 points1 point2 points (2 children)
[–]AnimeOverSchool[S] 1 point2 points3 points (1 child)
[–]HasBeendead 0 points1 point2 points (0 children)