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

  • Home
  • SEARCH
  • 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 8734335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:49:25+00:00 2026-06-13T09:49:25+00:00

define a string define string’s len print true if the string len is even

  • 0
  1. define a string
  2. define string’s len
  3. print true if the string len is even and the right half identical to the left half, else – print false.

I need to do it only in 3 lines and it has to work for every string len without change the condition in (3).

We didn’t learn or loop yet. It supposed to be with slice.

please help.


i tried to do it:

some_string = "bb" 
str_len = len (some_string),str(a)
if str_len%2==0 and some_string[0:a/2]==some_string[a/2:0]: print "True"
else: print "False"

but something went wrong

  • 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-13T09:49:25+00:00Added an answer on June 13, 2026 at 9:49 am

    Your code is almost fine, just a little improvement needed. You don’t actually need to check for even length using modulus(%) operator, as the second condition will automatically take care of it.

    So, Here’s how your code would look: –

    >>> def check_str(value):
            mid = len(value) / 2
            return True if value[:mid] == value[mid:] else False
    
    >>> check_str("abab")
    True
    >>> check_str("abb")
    False
    >>> check_str("aaba")
    False
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to define 'string-right' the procedure (define string-right (lambda (x) (substring x (quotient
I need to define a string that will include a string that changes (i
I'm programming in VB.NET using Visual Studio 2008. I need to define a string
I tried to split two fields from a binary string: -define(S,<<M\0\0\0522039355099,010100000008,0,010170000000,0,0,0,0,0,0,,,0,0,,‌​0110,00,150,0,0,0\0>>).<<Message_length:4/binary,Msg/binary>> = S. the
So, as described on this msdn page , when you define a Connection String
I want to define the block as a string, then create the lambda. The
When we define a property like public string Name {get; set;} dot net can
Is it possible to define an instance method in ruby from a string (the
Can I define a background worker in a method ? private void DownLoadFile(string fileLocation){
Can't define (?) operator overload on type: type Foo = val s : string

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.