0

Here is the code I have:

def generate(x)
    two = {}
    for x in range(1,7315):
        two.update({vowels[random.randint(0,4)] + alpha[random.randint(0,21)]:0})  
        return two      
generate(x)

this only returns a single value, how could I make it return multiple values?

johnbowen
  • 121
  • 6

3 Answers3

0

return a tuple with your values

def returnTwoNumbers():
    return (1, 0)

print(returnTwoNumbers()[0])
print(returnTwoNumbers()[1])

#output:
#1
#0

It also looks like you're trying to get a random vowel from your list of vowels. Using random.choice is a much more readable way to get a random item from a list:

import random
vowelList = ['a', 'e', 'i', 'o', 'u']

print (random.choice(vowelList))
Keatinge
  • 4,330
  • 6
  • 25
  • 44
0

You can use a tuple to return multiple values from a function e.g.:

return (one, two, three)
heemayl
  • 39,294
  • 7
  • 70
  • 76
0

You have wrong indentation

def generate():
    two = {}
    for x in range(1,7315):
        two.update({vowels[random.randint(0,4)] + alpha[random.randint(0,21)]:0})  
    return two      

twos = generate()
Sergey Gornostaev
  • 7,596
  • 3
  • 27
  • 39