Python Forum
Unexpected output, not sure why
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected output, not sure why
#2
Quote:if Name != "Justin" and Name != "justin": #makes it so he can type in with OR without caps
print(A) #your lying to me but lets continue
Color= input("What is your favorite color?")

if Name == "Justin" and Name == "justin": #answer was as expected continue collecting info
Color = input("What is your favorite color?")
I think you meant or not and. Name cannot be both Justin and justin at the same time.

You can utilize python builtins and convert the input to lowercase, then you dont have to check for uppercase

if name.lower() == 'justin':
Then name could be justin, JUSTIN, Justin, etc.

Color is never defined because of the issue above. None of your if conditions are ever true because Name cannot be both Justin and justin. It however can not be both justin and Justin. If you put anything other than either of those, it runs through as you are saying "if not both". You want the or operator here, not and.

There is another package whois, that has versions for python 2 and 3, it also is old, but at least can be installed with pip

pip install whois
Recommended Tutorials:
Reply


Messages In This Thread
Unexpected output, not sure why - by Ixxxxxx - Jan-31-2018, 07:41 PM
RE: Unexpected output, not sure why - by metulburr - Jan-31-2018, 07:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unexpected output Starter 2 493 Nov-22-2023, 12:08 AM
Last Post: Starter
  Unexpected Output - Python Dataframes: Filtering based on Overlapping Dates Xensor 5 722 Nov-15-2023, 06:54 PM
Last Post: deanhystad
  Unexpected output while using random.randint with def terickson2367 1 519 Oct-24-2023, 05:56 AM
Last Post: buran
  Unexpected output from df.loc when indexing by label idratherbecoding 6 1,208 Apr-19-2023, 12:11 AM
Last Post: deanhystad
  unexpected output asyrafcc99 0 1,510 Oct-24-2020, 02:40 PM
Last Post: asyrafcc99
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,061 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Unexpected output palladium 4 2,761 Jan-11-2020, 03:26 PM
Last Post: palladium
  Unexpected output: if statement CabbageMan 1 1,771 Sep-04-2019, 04:12 PM
Last Post: ThomasL
  Unexpected Output using classes and inheritance langley 2 1,958 Jul-04-2019, 09:33 AM
Last Post: langley
  float multiplication - unexpected output inesk 3 3,357 Dec-11-2018, 10:59 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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