Reputation: 99
consider the following code when i run it only the line after while loop executed and the if statement seems like it doesnt exist i cannt realize where the error exactly.
while True:
IN = input(" ====================================== \n CPU scheduler console application: \n ====================================== \n 1.FCFS \n 2.SJF \n 3.Periority algorithm \n 4.Round robin \n 5.Exit \n Enter the chosen algorithm to run: ")
if IN == 1:
Processes = input(" Enter the processes times & arrival times separated by a comma: ")
BurstTimes = Processes[::2]
ArrivalTimes = Processes[1::2]
print BurstTimes, '\t\t', ArrivalTimes,
else:
print 'Good Bye!'
Upvotes: 0
Views: 44
Reputation: 28272
Indent the if
clause:
while True:
IN = raw_input(" ====================================== \n CPU scheduler console application: \n ====================================== \n 1.FCFS \n 2.SJF \n 3.Periority algorithm \n 4.Round robin \n 5.Exit \n Enter the chosen algorithm to run: ")
if IN == '1': #change this to a string
Processes = input(" Enter the processes times & arrival times separated by a comma: ")
BurstTimes = Processes[::2]
ArrivalTimes = Processes[1::2]
print BurstTimes, '\t\t', ArrivalTimes,
else:
print 'Good Bye!'
It's a better practice to use raw_input
and strings instead of input
- which evaluates your input and might be harmful to your code.
Upvotes: 2