This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

cant get this if elif else working  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
really dont know why im battling here...done a few of these before



fail is working...and everything else is just pass
 
Marshal
Posts: 63804
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to have to assume that elif works the same as it would in other languages. What you want is:-If the boundary value is included in the higher category, start low and use <
If the boundary value is included in the lower category, start high and use > An example of that is weights of parcels.
No need for ≤ or ≥.

Are you allowed to write x >=50 < 65 at all?
 
Saloon Keeper
Posts: 9989
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know Python, but it looks like the comparison operators return a value that you can compare to another number. For instance, moduleOneTotal >= 50 might return 0 or 1, which you then compare with 65. This will always be true.
 
Campbell Ritchie
Marshal
Posts: 63804
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have the same problem in C, where you probably do get 0/1, or in Forth, where you get 0/−1.
 
Ranch Hand
Posts: 67
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start from lowest then to highest.

I hope it helps.

 
I'm full of tinier men! And a tiny ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!