Edited by pythonchallenge, 16 August 2011 - 04:09 PM.
2 replies to this topic
#1
Posted 15 August 2011 - 11:23 PM
how do i do this
|
|
|
#2
Posted 15 August 2011 - 11:58 PM
Use [ code ]Text[/ code ] around your code
of course without space
of course without space
#3
Posted 16 August 2011 - 12:10 AM
Debug the longest string
you need to first get the longest string out of the three inputs and then assign the result to the variable 'longest'.
For example :
you can add the other conditions in similar manner to check for b and c. Hope this helps :)
longest = "" if len(a) >= len(longest): longest = a elif len(b) > len(longest): longest = a else: longest = c print "The longest line was", longesthere you are assigning individual strings to 'longest' after comparing each string to 'longest'.
you need to first get the longest string out of the three inputs and then assign the result to the variable 'longest'.
For example :
if len(a) > len(b)
{
if len(a) > len(c)
{
// Now its proved that a is the longest string, so assign it to 'longest'
longest = a;
}
}
you can add the other conditions in similar manner to check for b and c. Hope this helps :)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









