Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Help for newbie with if/else statement that has or statement
Hello there,
I'm trying make a simple code (to practice for loops and if/elif statements) to give a person 3 choices of what kind of book he is looking for. He can do this three times (attempt).
My problem is that no matter what I enter 1.,2. or 3 it returns "you picked Non fiction.
Can someone please tell me what I'm doing wrong?
(after trying to figure out myself the problem for about a half an hour it is quite aggravating)
Thank you very much
for attempt in range (3):
    print('What kind of book are you looking for?')
    print('1. Non fiction')
    print('2. Fiction')
    print('3. Text book')
    if type=='1'or 'Non fiction':
          print('You picked Non fiction')
    elif type=='2'or'Fiction':
        print('you picked Fiction')
    elif type== '3' or 'Text book':
        print('you picked Text book')
        print('Try again')
Please see the forum thread Multiple expressions with or keyword
Yoriz I can't thank you enough. (You saved my sanity.) That post you sent me is excactly what I wanted.
micseydel and Yoriz like this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  I need help to solve this task using while statement rico4pepe 6 399 Apr-02-2020, 11:34 AM
Last Post: pyzyx3qwerty
  Filtering with IF Statement Mike2607 10 545 Nov-29-2019, 07:18 PM
Last Post: perfringo
  Trying to get an if..elif..else statement to run. Azurato 4 424 Jul-29-2019, 12:17 PM
Last Post: ichabod801
  Else Statement Not Working SenkouSimmer 4 480 Jul-22-2019, 11:42 AM
Last Post: jefsummers
  syntax error in an if statement at the else ? Just_started 2 415 Mar-07-2019, 08:35 PM
Last Post: Just_started
  Decision statement problems erfanakbari1 2 470 Mar-06-2019, 12:27 AM
Last Post: woooee
  How to print a statement if a user's calculated number is between two floats Bruizeh 2 482 Feb-10-2019, 12:21 PM
Last Post: DeaD_EyE
  if/else statement only outputs else statement regardless of input KameronG 2 472 Feb-08-2019, 08:04 AM
Last Post: KameronG
  While loop and If Statement farzankh 3 689 Jan-27-2019, 10:13 PM
Last Post: stullis
  A three if statement problem I am having WarblingPasta 1 559 Nov-01-2018, 03:04 PM
Last Post: j.crater

Forum Jump:

Users browsing this thread: 1 Guest(s)