Question
I have only figured it out using the len function but can't figure it out without Function name : make_gamertag Parameters : a string representing
I have only figured it out using the len function but can't figure it out without
Function name : make_gamertag Parameters : a string representing our inspiration for the gamer tag, and a list of integers of where we want to index from (assume valid parameters will be passed in every time) Returns : A string representing the gamer tag that we end up with
Description : You are an aspiring gamer. The first step is making an intimidating gamertag, but you need some inspiration. Write a function that takes in a string and a list of integers and adds certain indices (specified in the list) from the string into your soon-to-be tag. Anytime the desired index does not exist in the string, add in a 0 zero to the gamertag, but if the index is valid, add the corresponding character as well as another x just for spice. When you have gone through all entries of the list, surround the tag with square [ ] brackets and return the string. You may assume that valid argument types will always be inputted for this function.
Note : You may NOT use the len( ) function, or you will not receive credit. You MUST use try/except in this function.
Test Cases : >>> aList = [20, 4, 50, 0, -2, 3] >>> aStr = "Aw Geez Rick" >>> tag1 = make_gamertag(aStr, aList) >>> print(tag1) [0ex0AxcxGx]
>>> aList = [19,8,17,6,15,4,13,2,11] >>> aStr = "LEEEeeeEEROY JEENNKKINS" >>> tag2 = make_gamertag(aStr, aList) >>> print(tag2)
[KxExNxexExexJxExYx]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started