I am a basic coding student (doing IDC 2000 as a logic get ed) and I am confused as to why my logic in this question structure keeps returning me this same list output:
1. $32,870.00
2. $657.40
3. $33,920.00
4. $678.40
5. TOTAL PAID COMMISION: $1335.80
6. REMAINING PROFITS/LOSS: $-285.80'1. $32,870.00
2. $657.40
3. $33,920.00
4. $678.40
5. TOTAL PAID COMMISION: $1335.80
6. REMAINING PROFITS/LOSS: $-285.80
Heres the full code. The objective is to display that list only if the user enters 'Y' or 'y'.
import sys,time,os
message=('-Stock Transaction Program-' '\n'
'\n'
'This program displays data reguarding''\n'
'a recent stock tranaction between Joe, his' '\n'
'stockbroker and ACME SOFTWARE...' '\n'
'\n'
'Would you like to see the following data?:' '\n'
'\n'
'1. The amount of money Joe paid for the stock.' '\n'
'2. The amount of commission Joe paid his broker' '\n'
' when he bought the stock.' '\n'
'3. The amount that Joe sold the stock for.' '\n'
'4. The amount of commission Joe paid his broker when he sold the stock.' '\n'
'5. Total paid commision to Joes stockbroker.' '\n'
'6. Profits/losses on this recent ACME SOFTWARE buy/sell.' '\n'
'\n')
def typewriter(message):
for char in message:
sys.stdout.write(char)
sys.stdout.flush()
if char !="\n":
time.sleep(0.004)
if char=='.':
time.sleep(0.5)
os.system("clear")
typewriter(message)
'\n'
answer=input('Y/N?:')
if answer=='Y' or 'y':
print('1. $32,870.00' '\n'
'2. $657.40' '\n'
'3. $33,920.00' '\n'
'4. $678.40' '\n'
'5. TOTAL PAID COMMISION: $1335.80' '\n'
'6. REMAINING PROFITS/LOSS: $-285.80')
elif answer=='N' or 'n':
print('You may close this program.')
else:
print('Entry not accepted' '\n'
'Please enter either "Y/y" for yes or "N/n" for no.')
So, main issue- any input I give to the keyboard at the boolean section returns that list.
PS. I know there's probably some organizational errors so advice helps. I really like coding and want to eventually be able to code bigger projects in python. The typewriter function is for a rolling text effect throughout variable "message" but it would be cool if someone could help me apply that effect to the whole body of text any time multiple lines of text are being printed.