List: more advanced concepts in list


more advanced concepts in list

# Creating and accessing tuples.

# retrieve hour, minute and second from user
hour = int( raw_input( "Enter hour: " ) )
minute = int( raw_input( "Enter minute: " ) )
second = int( raw_input( "Enter second: " ) )

currentTime = hour, minute, second   # create tuple

print "The value of currentTime is:", currentTime

# access tuple
print "The number of seconds since midnight is", \
   ( currentTime[ 0 ] * 3600 + currentTime[ 1 ] * 60 +
     currentTime[ 2 ] )


List methods:

listsMethods