PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 17, 2022

[FIXED] How to check if an integer is greater than another by a certain value in python?

 October 17, 2022     integer, python     No comments   

Issue

How could I check if the integers in y are greater than x by 2 or more?

For example if I have these variables and want to only return 7 and 10:

x = 3
y = [1,3,4,7,10]


Solution

x = 3
y = [1,3,4,7,10]

out = [] # list to store values

# Make a loop
for v in y:
    if v - x >= 2: # check if greater than x by 2 or more
        out.append(v) # store value


Answered By - Xynias
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing