refabro.blogg.se

Codecombat cs3 answers level 19
Codecombat cs3 answers level 19




codecombat cs3 answers level 19

Deja Brew You can concatenate (combine) strings with other strings, or numbers: numberofpotions = 5 hero.say("i have " + numberofpotions + " potions.") Use string concatenation to sing along with your friends! # You can add strings together, and add numbers into strings. if enemy: hero.say("go away, " + enemy.id)ĥ 5 / klo #2. # Command the peasants to battle and the peons to go away! friend = hero.findnearestfriend() if friend: hero.say("to battle, " + friend.id + "!") # Now find the nearest enemy and tell them to go away. Friend and Foe Ratkaisu # Peasants and peons are gathering in the forest. Commanding peasants has be shown to you: hero.say("to battle, " + peasant.id + "!") # The above line makes the hero say something like: "To battle, Sally!" Please note, peons and peasants don't like it when you simply call their name! You need to add (or concatenate )Ĥ 4 / klo something to the strings to get them to act. In this level you will need to command peasants to battle and peons to go away by combining their id with another string. If you have two strings "foo" and "bar", what do you expect the result of "foo" + "bar" to be? It's very simple, in fact, as "foo" + "bar" is the same as "foobar"! It simply combines (or concatenates ) the two strings together. Just like numbers can be added together using +, strings also can make use of the + operator. You can also concatenate strings stored in variables: hero.say("to battle, " + peasant.id) # Peasants and peons are gathering in the forest. hero.say("to battle, " + "Sally!") This will cause your hero to say "To battle, Sally!". Friend and Foe You can combine two strings into one using the the + operator. 1 1 / klo Computer Science 3 Python Introduces arithmetic, counters, advanced while loops, break, continue, arrays.






Codecombat cs3 answers level 19