175k views
0 votes
Write an expression whose value is the str that consists of the second through fifth characters of the str associated with s. Write in Python.

User DeltaTango
by
8.2k points

2 Answers

2 votes
>>> s = "012345678"
>>> s
'012345678'
>>> s[ 1 : 6 ]
'12345'



User Zaw Lin
by
8.6k points
7 votes

Answer:

text = input('Enter Text: ')

print(text[1:6])

Step-by-step explanation:

The programming language used is python 3.

The expression here is: print(text[1:6])

Expressions are a combination of values, variables, operators and calls to functions that need to be evaluated.

The above expression takes the text that is entered by the user in line 1 and uses the list slice attribute to extract only the string that consist of the second to fifth character.

The print function evaluated the argument and prints the result to the screen.

User Edder
by
8.8k points