Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Python

Noob here,

Do you know how I can get (search/find/ ?) the middle character of a string ?
0
Stephen1991
Asked:
Stephen1991
  • 2
1 Solution
 
-Richard-Commented:
s = "SomeString"
midChar = s[len(s)/2]

No searching is required - the "middle character" can be determined just by calculation.
0
 
Stephen1991Author Commented:
Wow.  That was awesome.  
0
 
Stephen1991Author Commented:
Thank you.
0
 
peprCommented:
It is better to use the // operator, i.e. midChar = s[len(s)//2].  It is the floored quotient also known as integer division.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now