Python
"Create a function generateString(char, val) that returns a string with val number of char characters concatenated together. For example generateString('a', 7) will return aaaaaaa. Additionally create the code to run your function and print out the new string."

Respuesta :

Create a function generateString(char, val) that returns a string with val number of char characters concatenated together. For example generateString('a', 7) will return aaaaaaa. Additionally create the code to run your function and print out the new string.

Explanation:

CODE :

import sys

import random

character= sys.argv[1]

count= int(sys.argv[2])

def generateString('char', count):

 random = char * count

 return random

print(character*count)

OUTPUT :

  • String('a' , 7)
  • aaaaaaa

In the above code, you are accepting a character, and a count value to go with it. When the value is updated, character is multiplied with the count, and the output is generated accordingly

ACCESS MORE