Level 6 - Types and Conditionals
Objective
Move the elf to the lever. Get the lever data lever.data()
and perform the appropriate action to the data. Submit the modified data using lever.pull(modified_data)
.
Hints
This level requires the use of operators to compare and modify data. This link on operators should help.
Data types will also need to be checked using conditionals in if
, elif
, else
statements. This link on conditionals should help.
You will also need to use conditionals to check data types. This link on types should help.
For example, if you want to check the type of a variable, you could use:
if type(var) == str:
print("Its a string!")
!!! abstract "Lever Objective"
Calling lever.data()
will return a boolean, a number, a list of integers, a string, or a dict with "a"
and an integer to you. For a boolean, return the inverse. For a number, return double the number. For a list of integers, return that list with each integer incremented by 1. For a string, return the string concatenated with itself. For a dict, return the dict with a
's value + 1. Submit this response using lever.pull(conditional_answer)
.
1 2 3 4 5 6 7 |
|
Solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|