Jump to content

HELP

- - - - -

  • Please log in to reply
2 replies to this topic

#1
pythonchallenge

pythonchallenge

    Newbie

  • Members
  • Pip
  • 3 posts
how do i do this

Edited by pythonchallenge, 16 August 2011 - 04:09 PM.


#2
GramCracker

GramCracker

    Newbie

  • Members
  • PipPip
  • 13 posts
Use [ code ]Text[/ code ] around your code

of course without space

#3
common_man

common_man

    Newbie

  • Members
  • Pip
  • 8 posts
Debug the longest string

longest = ""

if len(a) >= len(longest):

    longest = a

elif len(b) > len(longest):

    longest = a

else:

    longest = c


print "The longest line was", longest

here 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