Concatenation operators
# Use + for strings or lists
'a'+'b' # 'ab'
[1,2]+[3,4] # [1,2,3,4]
# Use .. to convert the right operand to a string
'a'..1 # 'a1'
# Use .. to modify lists
list=[1,2]
list..3
print(list) # [1, 2, 3]
Basic tips
- Use the conditional operator (
?:
)
- Functions can be assigned to variables
- Use
import … as …
- Use
print'string'
instead of print('string')
string.tr
is shorter than string.replace
for replacing/removing characters