একটি স্ট্রিংয়ের অক্ষরগুলো সোয়াপ করে নতুন স্ট্রিংয়ে কিভাবে রাখবো?

asked 08 Jan, 15:48

shishir's gravatar image

shishir
375

edited 08 Jan, 16:21

Mosharraf%20Hosain's gravatar image

Mosharraf Hosain ♦
16618


string = "helloworld"
startIndex = 0
endIndex = len(string)

#find the middle index of the satring
midIndex = startIndex + (endIndex - startIndex) / 2

# Copy first half of the string
firstHalf = string[startIndex : midIndex]

# Copy second half of the string
secondHalf = string[midIndex : endIndex]

# Join
swapped = secondHalf + firstHalf

print string
print swapped
permanent link

answered 08 Jan, 18:03

Ashfaqur%20Rahman's gravatar image

Ashfaqur Rahman
5099

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×33

question asked: 08 Jan, 15:48

question was seen: 40 times

last updated: 08 Jan, 18:03