Hey guys.
Im having some problems with python. I need to create a function that takes in two arguments where
the first is a sequence(string) of letters. The other is also a string but of integers, that tells me start and stop that I want to cut out from the sequence.

the fuction should return a string of the cut-out.
Can anyone give a clue?

Can you explain what you mean by string of integers (bytes? memoryview?) Also you must explain what you have tried to do and how the result differed from your expectations to show proper effort.

I think Pythonbeginner! means something like this: string of letters: 'abcdefgh' list of integers: [(2, 6)], how can you extract the letters from 2-6 (cefg)?

I think Pythonbeginner! means something like this: string of letters: 'abcdefgh' list of integers: [(2, 6)], how can you extract the letters from 2-6 (cefg)?

(cefg) what happened to "d".

Can anyone give a clue?

You can access the letters in a string by it's offset (note that the fifth offset is the sixth letter because you skip over the first 5--offest the pointer to after 5--to get to the start of the 6th):

``````string_of_letters='abcdefgh'
for ctr in range(2, 6):
print string_of_letters[ctr]``````

I think Pythonbeginner! means something like this: string of letters: 'abcdefgh' list of integers: [(2, 6)], how can you extract the letters from 2-6 (cefg)?

Something like:

``````letters = 'abcdefgh'
indexes = [(2, 6)]
print([letters[start:stop] for start, stop in indexes])``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.