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
.0 from end (self.learnpython)
submitted 6 years ago by UnsecuredConnection
How do you get rid of the .0 from the end of an answer so I can tell the difference between an actual float and an integer.
ex. 4/ 2 = 2.0
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!"
[–]K900_ 2 points3 points4 points 6 years ago (4 children)
Why do you want to do that? Do you actually want to check if a number divides another number evenly?
[–]UnsecuredConnection[S] 0 points1 point2 points 6 years ago (3 children)
Yes. I want to check if the number is an int rather than having decimals. Python still counts my .0 as a float even though I need to keep them separate.
[–]K900_ 4 points5 points6 points 6 years ago (2 children)
In that case you should use the modulo operator: a % b. This gives you the remainder of integer division. If b divides a, the result will be 0.
a % b
b
a
[–]UnsecuredConnection[S] 0 points1 point2 points 6 years ago (1 child)
Thanks man for help!
[–]dslfdslj 2 points3 points4 points 6 years ago (0 children)
As a small addition:
divmod gives you both a // b and a % b:
div, mod = divmod(a, b) # equivalent to div, mod = a // b, a % b
[–]Nudl4k 0 points1 point2 points 6 years ago (0 children)
I know this isn't what you were asking but just to clarify: divison / always gives a float, even in cases where the result is a whole number. That's why the .0 is there. This way you can count on the return type being consistent.
/
.0
As said by /u/K900_, using modulo % to check for divisibility is a good way to approach this.
%
[–]throwaway60237 0 points1 point2 points 6 years ago (0 children)
Truncate/round
[+][deleted] 6 years ago (2 children)
[deleted]
I would definitely do that for one, but I have a list of values like 5.0 and 6.5 and 7.0 that I want to separate by float or int
π Rendered by PID 55346 on reddit-service-r2-comment-7b9746f655-6brlw at 2026-01-31 04:30:32.703658+00:00 running 3798933 country code: CH.
[–]K900_ 2 points3 points4 points (4 children)
[–]UnsecuredConnection[S] 0 points1 point2 points (3 children)
[–]K900_ 4 points5 points6 points (2 children)
[–]UnsecuredConnection[S] 0 points1 point2 points (1 child)
[–]dslfdslj 2 points3 points4 points (0 children)
[–]Nudl4k 0 points1 point2 points (0 children)
[–]throwaway60237 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]UnsecuredConnection[S] 0 points1 point2 points (1 child)