You must use looping to solve the problem
Given the following variables:
slash = "/"
backslash = "\\"
asterisk = "*"
uscore = "_"
Define a function that builds the following patterns based on variables given above:
pattern1:
/\/\/\/\/\/\/\/\/\
pattern2:
*-*-*-*-*-*-*-*-*
Tip: You may pass those symbols to the function as arguments. For example, your function header could look as following:
def create_pattern(symbol1,symbol2):
where:
symbol1 will be assigned to slash
symbol2 will be assigned to backshash
The same for the second pattern:
symbol1 will be assigned to asterisk
symbol2 will be assigned to underscore
Once the function is ready, you can use it to print the following pattern on the screen:
create_pattern(slash,backslash)
create_pattern(asterisk,uscore)
create_pattern(asterisk,uscore)
create_pattern(asterisk,uscore)
create_pattern(slash,backslash)
def create_pattern(symbol1,symbol2):
j = int(input(''))
com = symbol1 + symbol2
return com * j
create_pattern('*','_')
5
Out[44]:
'*_*_*_*_*_'
Comments
Leave a comment