Python Forum
Help for newbie with if/else statement that has or statement
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')
Reply
#2
Please see the forum thread Multiple expressions with or keyword
Reply
#3
Yoriz I can't thank you enough. (You saved my sanity.) That post you sent me is excactly what I wanted.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  If statement question help Gatso100 4 598 Jan-09-2024, 11:53 AM
Last Post: Pedroski55
  Can't stop if statement from executing even though False + Messy code? monkeydesu 1 948 Oct-17-2022, 05:46 AM
Last Post: deanhystad
  Post IF Statement Input OrphanedSoul 2 2,273 Jun-04-2021, 05:03 PM
Last Post: deanhystad
  if statement not working g0g0g1g 2 1,603 Sep-08-2020, 05:40 PM
Last Post: nilamo
  While statement explanation alkhufu2 3 2,339 Sep-02-2020, 05:46 PM
Last Post: alkhufu2
  I need help to solve this task using while statement rico4pepe 6 9,183 Apr-02-2020, 11:34 AM
Last Post: pyzyx3qwerty
  Filtering with IF Statement Mike2607 10 5,107 Nov-29-2019, 07:18 PM
Last Post: perfringo
  Trying to get an if..elif..else statement to run. Azurato 4 2,565 Jul-29-2019, 12:17 PM
Last Post: ichabod801
  Else Statement Not Working SenkouSimmer 4 3,171 Jul-22-2019, 11:42 AM
Last Post: jefsummers
  syntax error in an if statement at the else ? Just_started 2 2,196 Mar-07-2019, 08:35 PM
Last Post: Just_started

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020