I am getting output - def

0 votes
st1="abcdef"
st2=st1[len(st1)//2:]
Print(st2)

Im getting output - "def"

But it should be "cdef" because the length of st1 is 6 and 6/2=3 (which indicates "c" in st1)

Nov 4, 2020 in Python by anonymous
• 8,880 points
50 views

1 answer to this question.

0 votes

You can make a change to your code in this way:

st1[3] = 'd'
answered Nov 4, 2020 by Gitika
• 65,930 points

Related Questions In Python

0 votes
1 answer

Why am I getting a error when I am printing two different data types in python?

different data type is being used. that ...READ MORE

answered Mar 6, 2019 in Python by Mohammad
• 3,230 points
203 views
0 votes
3 answers

i am installing wordcloud using pip but i am unable to do that ....i am getting the following error

Hi @ Prajwala  All the members here, I ...READ MORE

answered Sep 14, 2020 in Python by Richa sharma
6,650 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,259 views
0 votes
0 answers
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,691 views
0 votes
1 answer

i am getting an error on pycharm while installing packages

Hi, @There, $ pip install gevent --pre $ pip ...READ MORE

answered Oct 27, 2020 in Python by Gitika
• 65,930 points
312 views
0 votes
1 answer

i am getting this error "TypeError: tuple indices must be integers or slices, not Database"

Hi, @Shabaj, Regarding your query, I hope this ...READ MORE

answered Dec 10, 2020 in Python by Gitika
• 65,930 points
267 views