I needed two expected outputs but my code won't follow both at the same time.  - The first expected output is marked with green box and my output as well.  - The second output is marked with red box.  There's something wrong with my code. When I put print() on the first output so that the zero will go down,, the "Invalid Input" in the second expected output goes down as well. Really need help thanks

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I needed two expected outputs but my code won't follow both at the same time. 

- The first expected output is marked with green box and my output as well. 

- The second output is marked with red box. 

There's something wrong with my code. When I put print() on the first output so that the zero will go down,, the "Invalid Input" in the second expected output goes down as well. Really need help thanks!

1 vwhile (1):
b = int(input ("Enter num:"))
print()
k = b-1
if(b <= 0):
print ("Invalid input")
2
4
5
6
7
continue
8
else:
9
for i in range (0, b):
for j in range (0, k):
print(end = " ")
k = k-1
for m in range (0, 2*i+1):
if(m > 9):
print (m%10, end = "")
else:
10
11
12
13
14
15
16
17
print(m, end= "")
18
print('\r')
19
break
SECOND NEEDED OUTPUT
FIRST NEEDED OUTPUT
Your Output (stdout)
Your Output (stdout)
Enter
my code turns out wrong
hum:
Enter num:
wrong
Invalid input
Enter num:
Invalid input
012
01234
0123456
Enter num:
Invalid input
Expected Output
Enter num:
Enter num:
correct
Expected Output
012
01234
this is the correct one
Enter num: Invalid input
Enter num: Invalid 1nput
Enter num: Invalid input
0123456
Enter num:
Transcribed Image Text:1 vwhile (1): b = int(input ("Enter num:")) print() k = b-1 if(b <= 0): print ("Invalid input") 2 4 5 6 7 continue 8 else: 9 for i in range (0, b): for j in range (0, k): print(end = " ") k = k-1 for m in range (0, 2*i+1): if(m > 9): print (m%10, end = "") else: 10 11 12 13 14 15 16 17 print(m, end= "") 18 print('\r') 19 break SECOND NEEDED OUTPUT FIRST NEEDED OUTPUT Your Output (stdout) Your Output (stdout) Enter my code turns out wrong hum: Enter num: wrong Invalid input Enter num: Invalid input 012 01234 0123456 Enter num: Invalid input Expected Output Enter num: Enter num: correct Expected Output 012 01234 this is the correct one Enter num: Invalid input Enter num: Invalid 1nput Enter num: Invalid input 0123456 Enter num:
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education