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
1 Answer 1
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
Cory Kramer
119k19 gold badges176 silver badges233 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py