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
#1
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
Shevach
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')
    type=input()
    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')
    else:
        print('Try again')
Quote
#2
Please see the forum thread Multiple expressions with or keyword
Quote
#3
Yoriz I can't thank you enough. (You saved my sanity.) That post you sent me is excactly what I wanted.
Yoriz and micseydel like this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Trying to get an if..elif..else statement to run. Azurato 4 213 Jul-29-2019, 12:17 PM
Last Post: ichabod801
  Else Statement Not Working SenkouSimmer 4 275 Jul-22-2019, 11:42 AM
Last Post: jefsummers
  syntax error in an if statement at the else ? Just_started 2 246 Mar-07-2019, 08:35 PM
Last Post: Just_started
  Decision statement problems erfanakbari1 2 289 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 294 Feb-10-2019, 12:21 PM
Last Post: DeaD_EyE
  if/else statement only outputs else statement regardless of input KameronG 2 300 Feb-08-2019, 08:04 AM
Last Post: KameronG
  While loop and If Statement farzankh 3 398 Jan-27-2019, 10:13 PM
Last Post: stullis
  A three if statement problem I am having WarblingPasta 1 400 Nov-01-2018, 03:04 PM
Last Post: j.crater
  How to force print statement to print on one line wlsa 4 528 Oct-28-2018, 09:39 PM
Last Post: wavic
  Need of return in function if statement inside the function already returns Athul 5 774 Aug-16-2018, 10:19 AM
Last Post: DuaneJack

Forum Jump:


Users browsing this thread: 1 Guest(s)