Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Obviously, it would be better to convert numbers to strings once only.
This will work in the mentionned case since, in Python, "0" != 0.
Note that this solution will transform 0.0s into 0s, but in Python this shouldn't be a problem.
Exactly!
So the 'if a' checks for an empty string (' ') and skips adding it to the join statement if it is an empty string?
Read about python's boolean operations here.
In a list comprehension an
if
can be added which will cause only those elements which satisfy the if condition to be added to the list.Probably for fun/practice creating a class.
Sometimes the best way to learn how to do something is to apply it to an easy problem.. that way it is easier to see where it is going wrong.
In my experience... does this actually always work? There were weird test cases with '0' moving to the end of the !=0 list but before the =0 list.
Does this really cover all the test cases?
What does the ' if a ' part at the end do?
This comment is hidden because it contains spoiler information about the solution
Is it best to convert num1 and num2 to strings 1 time at the begining of the function, or to conver them every time the function runs through the loops? Advantages and Disadvantages?
I think the reasability increases when they are in the loop - everything stays perfectly clearly, but I could see how you wouldn't want to keep generating strings every time.
ohhhhhh lamnda's :D