Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
whats wrong with this code?
#5
(Aug-31-2017, 02:42 AM)ichabod801 Wrote: You rarely use is. The is operator checks to see if both objects are stored in the same place (basically). It checks not just for a string 'italy', but a particular instance of the string 'italy'.

== checks to see if two things are equal (they have the same value). It doesn't care where they're stored.

As for == not working, did you notice the other problem with the or operator? Read this tutorial about the problem.

I was completely wrong between "is" and "==" I spotted the difference and it had nothinggg to do between strings and numbers. I realized the code worked after I deleted the "or" off my statement. I read the tutorial, however, I never really understood it? I see I did the exact same mistake as his example of how to not use it. I was trying to put "or" to tell the computer to let it pass as true if they either put Italy or italy since there was no difference. I don't know what I have to do to let the computer know thats what I meant. The tutorial probably explained it, however, it tripped me out and it confused me.
Reply


Messages In This Thread
whats wrong with this code? - by Hussein26 - Aug-31-2017, 12:26 AM
RE: whats wrong with this code? - by hbknjr - Aug-31-2017, 01:06 AM
RE: whats wrong with this code? - by Hussein26 - Aug-31-2017, 02:22 AM
RE: whats wrong with this code? - by ichabod801 - Aug-31-2017, 02:42 AM
RE: whats wrong with this code? - by Hussein26 - Aug-31-2017, 02:53 AM
RE: whats wrong with this code? - by Sagar - Aug-31-2017, 08:07 AM
RE: whats wrong with this code? - by sparkz_alot - Aug-31-2017, 12:10 PM
RE: whats wrong with this code? - by Hussein26 - Sep-01-2017, 06:17 AM
RE: whats wrong with this code? - by Sagar - Sep-06-2017, 09:38 AM
RE: whats wrong with this code? - by Larz60+ - Sep-06-2017, 10:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 591 Nov-07-2023, 04:32 PM
Last Post: snippsat
  Something wrong with my code FabianPruitt 5 972 Jul-03-2023, 10:55 PM
Last Post: Pedroski55
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,751 Mar-27-2023, 07:38 AM
Last Post: buran
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 1,396 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 2,027 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,831 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  Wrong code in Python exercise MaartenRo 2 1,602 Jan-01-2022, 04:12 PM
Last Post: MaartenRo
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,684 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  VS Code debugger using wrong Python environment topfox 0 2,594 Jun-09-2021, 10:01 AM
Last Post: topfox
  Whats wrong with the elif? inunanimous93 3 2,580 Nov-30-2020, 03:58 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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