0

I have the following code which does not list out the bedrooms or baths with the number :

room = ('Bath','BedRoom')
for k in range(0-6):
 room = room[1] = str(1+k)
 print room

I wanted to see the output as 'Bedroom1','Bedroom2'...............'Bedroom6'

I am not sure what I am doing wrong here and appreciate your inputs.

Thanks!

David
6,5912 gold badges27 silver badges22 bronze badges
asked Oct 6, 2014 at 23:28

1 Answer 1

2
room = ('Bath','BedRoom')
for k in range(1,7):
 print room[1] + str(k)

Note that range(0-6) evaluates to range(-6) because it is doing 0 - 6 as subtraction.

Output

BedRoom1
BedRoom2
BedRoom3
BedRoom4
BedRoom5
BedRoom6
answered Oct 6, 2014 at 23:29
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.