Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def replicate_iter(times, data):
- try:
- if type(data) is not(int) and type(data) is not(str):
- raise ValueError("Wrong Input Found!")
- arr = [];
- if times < 0:
- return arr
- for i in range(times):
- arr.append(data)
- return arr
- except(AttributeError,TypeError):
- raise ValueError("Wrong Input Found!")
- def replicate_recur(times, data):
- try:
- if type(data) is not(int) and type(data) is not(str):
- raise ValueError("Wrong Input Found!")
- arr = []
- def recur(times, data):
- if times <= 0:
- return arr
- else:
- arr.append(data)
- return recur(times - 1, data)
- return recur(times, data)
- except(AttributeError,TypeError):
- raise ValueError("Wrong Input Found!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement