Jan-15-2019, 02:51 AM
(Jan-15-2019, 02:40 AM)Drone4four Wrote: In order for a function to properly return value, when the function is called, it’s necessary to declare it as a variable. I see now.
Actually, defining a variable is not necessary, the return statement is necessary. This works just fine:
def three(): return 5
(Jan-15-2019, 02:40 AM)Drone4four Wrote: But seeing someone demonstrate enumerate in the context of my fake credit card redaction task here I think would really help me understand the concept better.
def ccredact(card_string): redacted = [] for letter_index, letter in enumerate(card_string): if letter_index < 12: redacted.append('*') else: redacted.append(letter) if letter_index in (3, 7, 11): redacted.append('-') return ''.join(redacted)
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures