2

I need to generate a random amount of string for a certain amount of times; so for example:

for k in range(5):
   print("Country", location)
   print("Animal", animal)

so location and animal will be randomly generated from a list, and each of the 5 times it gets printed, it will have random number of locations and animal, so for every iteration a random number of locations and animals will be printed from a given list

  • 1 country and 4 animals it should be in the second iteration? Isn’t it – Raman Mishra May 04 '18 at 03:52
  • @RamanMishra what i mean is that for every iteration a random number of locations and animals will be printed – Chadwick Andrew May 04 '18 at 03:56
  • This is not similar to the question that has been said is a duplicate of this as this randomly generates different number of strings from a list instead of just one string from a list – Chadwick Andrew May 04 '18 at 04:01
  • if I showed you how to add 2 numbers, surely you can figure out how to add 10 of them? – cs95 May 04 '18 at 04:10
  • Anyway, without further context/explanation/justification of _why_ your question is different in the form of a meaningful [mcve], I am not inclined to reopen this question. As it stands your question is unclear and open to multiple interpretations—this is mine. – cs95 May 04 '18 at 04:11
  • Also see: https://stackoverflow.com/questions/12501956/randomly-select-x-number-of-items-from-class-list-in-python – cs95 May 04 '18 at 04:45

0 Answers0