Question was 6 or more.if he consider 7 word string then ans was A.if he consider 6 words string then answer was B
>>> str = 'examtop'
>>> str[1:-2]
'xamt'
>>>
print(string[1:-2]): Print the slice of string from index 1 (inclusive) to the second-to-last index (exclusive).
The slice includes characters from index 1 to index -3.
B. 3. Analyze these three cases and it will be easily visible that it always 3:
string="ABCDEFGHIJ"
print(string[1:-2])
string="ABCDEFGHI"
print(string[1:-2])
string="ABCDEFG"
print(string[1:-2])
if the string has 6 letters, the ans is B, if we keep on increasing the length of string, the output string length will also increase.
for example:
>>> str = '1234567'
>>> str[1:-2]
2345
>>> str = '12345678'
>>> str[1:-2]
23456
input 7 letter string--output 4 letter
input 8 letter string--output 5 letter
the -2 portion of the slice means that the sliced string will always proportionally increase in size as well compared to the original string. It only ever slices up to the last 2 characters in the string.
the question is asking for the difference in length between the original string and the sliced string. So you have to subtract the length of the slice from the original. Youll find its 3 every time
If the word has 6 letters, for example
str='naveen'
print(str[1:-2])
The answer is B, which is 3 chars
If the word has 7 letters then the answer is 4 chars
str1='Atharva'
print(str1[1:-2])
The answer is A, it has 4 chars
There is not a right answer on here because it really depends on how long the string is. If it has six letters then print will produce three of those letters. It'll increase depending on how many letters are in the string.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Avidulam
Highly Voted 4 years, 8 months agopshdreddy
Highly Voted 4 years, 6 months agoM7mdAl7aj
4 years, 5 months agoDarkhorse7979
4 years, 4 months agozantrz
Most Recent 9 months, 2 weeks agozantrz
9 months, 2 weeks agovale_76_na_xxx
5 months, 3 weeks agoTheFivePips
11 months, 3 weeks agovarshu_0708
1 year, 6 months agovarshu_0708
1 year, 6 months agoTheFivePips
11 months, 3 weeks agoTheFivePips
11 months, 3 weeks agonaveenbv80
1 year, 12 months agoN9
2 years, 2 months agoBenM1911
2 years, 11 months agoAtulVSharma
3 years, 1 month agoJesuisfort
3 years, 6 months agoJesuisfort
3 years, 7 months agoecko
4 years, 2 months agoFR99
4 years agowolverin3
4 years agowolverin3
4 years agoNehuuu
4 years, 2 months agopremaseem
4 years, 3 months agoSaifu
4 years, 6 months ago