Python Forum
Print different positions in loop from functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print different positions in loop from functions
#4
you need to swap outer and inner loop

def function_1():
    return "Hello Sir", "Hello You", "Hello Mam", "Hello Though"
 
def function_2():
    return "Bye to me", "Bye to you", "Bye to everyone", "Bye to noone"
 
for x in function_2():
    for y in function_1():
            print(y, x)
Output:
Hello Sir Bye to me Hello You Bye to me Hello Mam Bye to me Hello Though Bye to me Hello Sir Bye to you Hello You Bye to you Hello Mam Bye to you Hello Though Bye to you Hello Sir Bye to everyone Hello You Bye to everyone Hello Mam Bye to everyone Hello Though Bye to everyone Hello Sir Bye to noone Hello You Bye to noone Hello Mam Bye to noone Hello Though Bye to noone
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Print different positions in loop from functions - by buran - Oct-16-2019, 07:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  help with commas in print functions kronhamilton 11 3,616 Feb-10-2022, 02:02 PM
Last Post: mishraakash
Exclamation question about input, while loop, then print jamie_01 5 2,750 Sep-30-2021, 12:46 PM
Last Post: Underscore
  why print('\n') produced 2 new lines instead of 1 - Located inside a FOR loop JulyFire 2 2,602 Jan-10-2021, 01:50 AM
Last Post: JulyFire
  Adding Sliced Positions Gizzmo28 1 1,643 Nov-05-2020, 02:46 AM
Last Post: bowlofred
  Read characters of line and return positions Gizzmo28 2 2,077 Nov-04-2020, 09:27 AM
Last Post: perfringo
  Unable to print stuff from while loop Nick1507 4 2,409 Sep-17-2020, 02:26 PM
Last Post: Nick1507
  Print output in single file using pramika loop deepakkhw 1 2,122 Jul-11-2020, 11:57 AM
Last Post: j.crater
  Unable to combine print statements in for loop adeana 2 2,046 Jun-12-2020, 05:08 PM
Last Post: adeana
  Create, assign and print variables in loop steven_tr 10 4,470 May-28-2020, 04:26 PM
Last Post: ndc85430
  writing in particular positions clarablanes 5 2,875 Apr-13-2019, 04:07 PM
Last Post: clarablanes

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020