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,870 points
389 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,770 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
1,032 views
0 votes
3 answers

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

word cloud is not supported for python ...READ MORE

answered Apr 15, 2020 in Python by anonymous
33,023 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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
+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,790 points
4,042 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,770 points
2,444 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,770 points
1,158 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP