Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9060221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:10:16+00:00 2026-06-16T15:10:16+00:00

I am getting two strings in the following way which contain integer values. I

  • 0

I am getting two strings in the following way which contain integer values. I have tried all options but always got False as a result.

    string1    = element.__dict__.get('layer')    # '7'

    temp_string2,temp_string3=temp_key.split(':') # temp_key = '7:12'

    if string1 == temp_string2:
          print "data found"

I did not get True although both contain the same value. Can I have some input regarding this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:10:18+00:00Added an answer on June 16, 2026 at 3:10 pm

    Based on what I saw in the comment stream

    Could you add print repr(string1), repr(temp_string2) to your code to
    show us what the variables contain?

    I got 7 and ‘7’. How will I fix this isssue. why is this diffirence.I
    got understanding that it would be string in both case

    Its evident, you are comparing an integer with a string.

    If print repr(string1), returns 7 and print repr(temp_string2) returns "7" then string1 , which is

    string1    = element.__dict__.get('layer')
    

    should be an integer

    So you have to convert string1 to integer before comparing

    if str(string1) == temp_string2:
         print "data found"
    

    or convert it to a string after retrieving the value from dictionary

    string1 = str(element.__dict__.get('layer'))
    

    Strangely enough, its a very unconventional way of accessing a the get method of the dict, instead you could have simply done a member referencing with . notation

    string1    = element.get('layer')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am comparing two strings using following code string1.Contains(string2) but i am not getting
I have two Sets of Strings, with each in the following format: Set1(Names) Set2(Sizes)
I'm getting the following two errors when loading my page: Notice: Undefined variable: realtor
I'm trying to make two Kinects getting along under the same application. I've tried
I have a list which i am getting from database.I have 6 elements in
So I have a CSV with two columns that contain dollar amounts in string
I'm getting this linker error. I know a way around it, but it's bugging
I have following strings (I'm dealing here with the names of Tennisplayers): string bothPlayers
Not sure what I'm doing wrong but I have two services one is WCF
I am getting trouble with the following matter.Let's say, I have some string in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.