Python Forum
print two different sequence number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print two different sequence number
#1
Hi all I'm studying python recently and I'm newbie on programming language also
I'm writing a pyhthon code that print two different sequence number, the first one composed with 1,2,3,4,..n the second one with 1,5,9.13,.m
So I'd like to obtain an output like this:

1 1
2 5
3 9
4 13
5 17
....

I've tried with the following "for loop nested" but the result is not what I'm looking for

numeri1 = range(1,10)
numeri2 = range(1,10,4)

for elemento_1 in numeri1:
   for elemento_2 in numeri2:
      if elemento_1 <= elemento_2:
      print (elemento_1, elemento_2)
Infact the output obtained using this code is the following
1 1
1 5
1 9
2 5
2 9
3 5
3 9
4 5
4 9
5 5
5 9
6 9
7 9
8 9
9 9

So..Have you got any suggestion for modify this code to get the correct output?
Anyway is the "for loop nested" the right way or there is another way?
Thanks
Riccardo
Reply


Messages In This Thread
print two different sequence number - by mantonegro - Nov-16-2020, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print Player Name and Number of Pokemon webmanoffesto 1 1,164 Aug-23-2022, 08:54 PM
Last Post: deanhystad
  Sequence Generator - Long number krux_rap 3 2,417 Aug-19-2020, 06:37 PM
Last Post: buran
  Print the number of items in a list on ubuntu terminal buttercup 2 2,012 Jul-24-2020, 01:46 PM
Last Post: ndc85430
  Beginner Code, how to print something after a number of turns (guessing game) QTPi 4 2,913 Jun-18-2020, 04:59 PM
Last Post: QTPi
  Print 'X' a number of times Than999 1 2,714 Jan-18-2020, 06:41 PM
Last Post: Larz60+
  how do I make a number only print once but the number keeps on decreasing? syafiq14 5 3,077 Jan-03-2020, 10:34 AM
Last Post: perfringo
  print number of a list line per line lateublegende 2 2,798 Mar-20-2019, 04:07 PM
Last Post: lateublegende
  Repeating same number in sequence Rudinirudini 6 4,370 Oct-28-2018, 07:44 PM
Last Post: DeaD_EyE
  How to get number with print statement Rehan11 1 2,354 Jul-28-2018, 02:01 PM
Last Post: buran
  Unable to print the exact Float values when I convert LIST to Sequence of Tuples? preethamalluri 1 2,518 Jul-12-2018, 09:03 AM
Last Post: buran

Forum Jump:

User Panel Messages

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