had an error for this program, Can you show me how to fix it,please?

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Question

I had an error for this program, Can you show me how to fix it,please?

1 import sys
2
3 args = sys.argv
4 height
int(args[1])
args[2]
6 if height % 2 == 0:
5 name =
7
print('Error : tile height must be an odd number')
8 elif len(name) > 3 * height:
9.
print('Error : name must fit within', height
* 3, 'characters')
10 else:
11
width =
height * 3
12
middleDashes = width
len (name)
middle = ' -' * (middleDashes // 2) + name.upper () +
for i in range (1, height // 2 + 1):
print("-" * ((width
13
* (middleDashes
middleDashes // 2)
14
15
(3 * (2 * i
1))) // 2) +
"+ | +" * (i - 1) + "+|+" + "+|+" * (i - 1) + "-" * ((width
(3 * (2 * i - 1))) // 2))
16
print(middle)
17
for i in range (height /| 2, 0, -1):
18
print("-" * ((width
(3 * (2 * i - 1))) // 2) + "+|+" * (i - 1) + "+|+" + "+|+" * (i - 1) + "-" * ((width
(3 * (2 * i - 1))) // 2))
/home/tile.py Spaces: 4 (Auto)
All changes saved
Terminal
V Mark
[user@sahara ~]$ python3 tile.py
Traceback (most recent call last):
File "/home/tile.py", line 4, in <module>
height = int(args[1])
IndexError: list index out of range
[user@sahara ~]$
Reset
Transcribed Image Text:1 import sys 2 3 args = sys.argv 4 height int(args[1]) args[2] 6 if height % 2 == 0: 5 name = 7 print('Error : tile height must be an odd number') 8 elif len(name) > 3 * height: 9. print('Error : name must fit within', height * 3, 'characters') 10 else: 11 width = height * 3 12 middleDashes = width len (name) middle = ' -' * (middleDashes // 2) + name.upper () + for i in range (1, height // 2 + 1): print("-" * ((width 13 * (middleDashes middleDashes // 2) 14 15 (3 * (2 * i 1))) // 2) + "+ | +" * (i - 1) + "+|+" + "+|+" * (i - 1) + "-" * ((width (3 * (2 * i - 1))) // 2)) 16 print(middle) 17 for i in range (height /| 2, 0, -1): 18 print("-" * ((width (3 * (2 * i - 1))) // 2) + "+|+" * (i - 1) + "+|+" + "+|+" * (i - 1) + "-" * ((width (3 * (2 * i - 1))) // 2)) /home/tile.py Spaces: 4 (Auto) All changes saved Terminal V Mark [user@sahara ~]$ python3 tile.py Traceback (most recent call last): File "/home/tile.py", line 4, in <module> height = int(args[1]) IndexError: list index out of range [user@sahara ~]$ Reset
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning