+ 3
Python Core
Why does it tell me invalid syntax on this code from a lesson. if type==“Visa“ or type==“Amex“ print(“Accepted“)
12 Antworten
+ 3
if (type=='Visa' or
type=='Amex'):
print('Accepted')
+ 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..
+ 1
you need to put a ":" at the end of the second line
+ 1
I forgot it here but i have it in the code it still doesnt work
+ 1
What is type in code?
+ 1
Instead of or you have to write ||
0
It works thanks but why does this: ‘ works and this: “ not?
0
Ah thank you
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)
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
- 1
I try it noe