Noob question because I am new to Python but I am working on a side project where each of these voltages (0.3, 0.32, etc) are used as an input, and then that input generates a probability in an output file.
This is the output I'm looking for:
Input: 0.3 Probability = 7.509
Input 0.32 Probability = 1.399
Input 0.34 Probability = 2.773
Input 0.36 Probability = 0.127
...
This is the output I'm getting:
0.3
Probability = 7.509
0.3
Probability = 1.399
0.3
Probability = 2.773
0.3
Probability = 0.127
I'm having trouble putting the print(str(voltage)) statement in the right location to get the output that I want... As you can see, it is repeating the voltage over and over.
Here's the code, thank you for your time I appreciate you:
prob=[]
voltages = [0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5]
for voltage in voltages:
update_code(voltage)
os.system("hspice pbit.sp >output.txt")
def search():
with open('output.txt') as f:
datafile = f.readlines()
for line in datafile:
if 'probability' in line:
prob.append(line)
return True
return False
if search():
for voltage in voltages:
for items in prob:
print(str(voltage))
print(items)
else:
print('False')