+ 1

The below code keeps giving bugs related to NASA and codes remain prematurely. How shall correct the debug.

text1 = input("hello: ") text2 = input("nasa: ") text3 = input("bmw: ") # convert to uppercase text1_uppercase = text1.upper() text2_uppercase = text2.upper() text3_uppercase = text3.upper() # display on the screen print(text1_uppercase) print(text2_uppercase) print(text3_uppercase) # the other code blog below is not running either, even after I myself modified the nasa word in the line related to the bugs message. # Get user input text1 = input("hello: ") text2 = input("nasa: ") text3 = input("bmw: ") # Check if user input is NASA if text2.upper() != "NASA": print("Please enter NASA when asked for a company.") else: # Convert to uppercase text1_uppercase = text1.upper() text2_uppercase = text2.upper() text3_uppercase = text3.upper() # Display on the screen print(text1_uppercase) print(text2_uppercase) print(text3_uppercase)

9th Nov 2023, 8:33 AM
BEHCET AYTIMUR AHISKA
BEHCET AYTIMUR AHISKA - avatar
7 Answers
+ 2
Bob_Li If both parts belong to the same program, all the text1, 2 and 3 will get a new value because they asked for user inputs, so as the text_uppercases' values. BEHCET AYTIMUR AHISKA If you are referring the bug when you run the code in playground, you have to provide ALL inputs after you hit the run button. Inside the input box, enter your inputs. Each input on a separate line.
9th Nov 2023, 10:08 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 2
Wong Hei Ming You are right. but there is still a bugfix to be done. The second part condition should be # Check if user input is NASA if text2 != "NASA": print("Please enter NASA when asked for a company.")
9th Nov 2023, 11:14 AM
Bob_Li
Bob_Li - avatar
+ 1
I can't found any bug in the program. What bug are your referring to? What is your input and the expected output?
9th Nov 2023, 9:49 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
maybe you should reset text1, text2 and text3 to "" before going to the second part.
9th Nov 2023, 9:53 AM
Bob_Li
Bob_Li - avatar
+ 1
Bob_Li I would say using a "not equal" to make evaluation can lead to confusion, especially chain with other function. If we get a big thumb and miss type 'masa', with OP's code it is evaluated to False and jump to the else part.
9th Nov 2023, 2:12 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
It looks like there might be an issue with the comparison in the second code block. Instead of comparing the uppercase version of text2, you may want to compare the uppercase version of the user input directly. Here's the corrected code: # Get user input text1 = input("hello: ") text2 = input("nasa: ") text3 = input("bmw: ") # Check if user input is NASA if text2.upper() != "NASA": print("Please enter NASA when asked for a company.") else: # Convert to uppercase text1_uppercase = text1.upper() text2_uppercase = text2.upper() text3_uppercase = text3.upper() # Display on the screen print(text1_uppercase) print(text2_uppercase) print(text3_uppercase) This change ensures that the comparison is done with the uppercase version of the user input directly, addressing the issue you mentioned. If the problem persists, please provide more details about the specific error messages or unexpected behavior you are encountering.
10th Nov 2023, 2:55 PM
Atif
Atif - avatar
0
n1 =("a+b") n2 =("enter any number for addition") n3 =("a*b") n4 =("enter any number for multiplication") check ={"n2 & n4 "} answer = ("check") print {f"check"}
10th Nov 2023, 4:02 PM
ajah chidera
ajah chidera - avatar