Thank you. My class "Mnemonic" is used to generate a name out of a given phone number. For example, if the input of phone number is 6862377, then some possible outputs are:
print('"' + m.make('6862377') + '"') # "ounadrr" print('"' + m.make('6862377') + '"') # "ounadrs" print('"' + m.make('6862377') + '"') # "ntobers" print('"' + m.make('6862377') + '"') # "ouncerr" print('"' + m.make('6862377') + '"') # "ntoadrr" print('"' + m.make('6862377') + '"') # "muncess" print('"' + m.make('6862377') + '"') # "ounadrs" print('"' + m.make('6862377') + '"') # "munadrs" print('"' + m.make('6862377') + '"') # "ouncers" print('"' + m.make('6862377') + '"') # "otoadrr"I tried to make a few print statements in my code, and some print statements are not even showing in my terminal. I don't know why.
def make(self,number): self.num = number self.s1='' self.s3='' print("First number is", self.num[0]) print("Letters associated with",self.num[0],"is",self.letters[int(self.num[0])][1]) i = 0 self.s1+=self.random.choose(self.letters[int(self.num[0])]) print("String s1 is",self.s1) while i < len(self.num): # self.s4 +=self.random.choose(self.letters[int(self.num)]) self.s2 = '' self.s2 += self.follow[self.s1] print("String s2 is", self.s2) print("Length of s2 is", len(self.s2)) j = 0 while j <= len(self.s2): found_char = False if self.s2[j]==self.letters[int(self.num[i+1])]: print("String next num is",self.letters[int(self.num[i+1])]) self.s3+=self.s2[j] found_char = True j+=1 print("String s3 is", self.s3) if found_char == False: return'' i=+1 self.s1 += self.random.choose(self.letters[self.s3]) print("String s1 is now",self.s1) return self.s1for instance, the last print statement does not show up in the terminal (I am using Intellij IDE now). I think my while loop with the counter j is messing up my code but I think my logic sounds reasonable. All I am trying to do is to check whether at each position in my string s2 contains a self.letters[int(self.num[i+1])][/python]. If it does, then I concatenate it to the new string s3. If none matches, I return an empty string. At then end, when I have a string s3 with all the matching letters in the string self.letters[int(self.num[i+1])], then I called the random.choose function again to pick a random letter out of that string and concatenate to string s1. Hmm I am having some thoughts about my while loop now, but I am working on them.