+ 3

Python Core

Why does it tell me invalid syntax on this code from a lesson. if type==“Visa“ or type==“Amex“ print(“Accepted“)

8th Nov 2022, 1:31 PM
12 Antworten
+ 3
if (type=='Visa' or type=='Amex'): print('Accepted')
8th Nov 2022, 1:36 PM
Компания Три А
Компания Три А - avatar
+ 3
'text' , "text" both single quotes, double quotes works fine. Both same in python. But you are not using none of those. You are using inverted quotes “ , ”, which are different..
8th Nov 2022, 1:51 PM
Jayakrishna 🇮🇳
+ 1
you need to put a ":" at the end of the second line
8th Nov 2022, 1:34 PM
Компания Три А
Компания Три А - avatar
+ 1
I forgot it here but i have it in the code it still doesnt work
8th Nov 2022, 1:34 PM
+ 1
What is type in code?
8th Nov 2022, 1:40 PM
Jayakrishna 🇮🇳
+ 1
Instead of or you have to write ||
10th Nov 2022, 12:55 PM
Ariba
0
It works thanks but why does this: ‘ works and this: “ not?
8th Nov 2022, 1:41 PM
0
Ah thank you
8th Nov 2022, 1:52 PM
0
It is be cool to not use build-in functions as a variables, but if u want to use it, use nameing form like this: type_ (add underscore to name of variable)
10th Nov 2022, 8:31 AM
Danila Khaminets
Danila Khaminets - avatar
0
def earliest_event_time(citizens): N = len(citizens) dp = [[[float('inf')] * (1 << N) for _ in range(3)] for _ in range(N + 1)] dp[0][0][0] = 0 for i in range(1, N + 1): for j in range(3): for k in range(1 << N): dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]) if j > 0: dp[i][j][k] = min(dp[i][j][k], dp[i][j - 1][k | (1 << (i - 1))] + citizens[i - 1][j - 1]) earliest_time = max(dp[N][2]) return earliest_time # Example usage: citizens = [ [18, 7, 6], [23, 10, 27], [20, 9, 14] ] print(earliest_event_time(citizens)) def main(): # Read the number of citizens N = int(input()) citizens = [] # Read the time taken by each citizen for COBOL programming, pole vault, and doughnut-eating for _ in range(N): times = list(map(int, input().split())) citizens.append(times) # Calculate the earliest event time earlie
12th May 2023, 5:52 AM
PINNINTI ESWARARAO
- 1
I try it noe
8th Nov 2022, 1:36 PM