The While Loop - currentCard exercise

Hello All,

In the section practice for While Loop, there is the current card exercise as below:

and it prints something like this (everytime different, but always ends with ‘spade’). I thought that the point of this loop is “not printing the ‘spade’”? I understand it stops when it hits spade, but i thought it shall not print out ‘spade’? or if not, in what way i can code it in a way not printing the ‘spade’ (but still using the same logic as it stops while it hits ‘spade’)? Sorry i hope i made myself clear. Thanks!!

diamond
diamond
heart
diamond
heart
heart
club
club
diamond
club
club
club
heart
spade

And at the Do While look exercise:

within the bracket, instead of ‘cupsAdded ++’, can i use ‘cupsAdded = cupsAdded ++’, and what’s the difference? Thanks!!

1 Like

you could print spade after the loop? You know for sure its a spade

why would you do that? cupsAdded++ is a shorthand for:

cupsAdded = cupsAdded + 1

so writing cupsAdded = cupsAdded ++ is the same as:

cupsAdded = cupsAdded + cupsAdded + 1
1 Like

Thanks for the answer! xx