Can I use the range operator with if statement in Swift?

You can use the “pattern-match” operator ~=: if 200 … 299 ~= statusCode { print(“success”) } Or a switch-statement with an expression pattern (which uses the pattern-match operator internally): switch statusCode { case 200 … 299: print(“success”) default: print(“failure”) } Note that ..< denotes a range that omits the upper value, so you probably want … Read more

How to set the subplot axis range

You have pylab.ylim: pylab.ylim([0,1000]) Note: The command has to be executed after the plot! Update 2021 Since the use of pylab is now strongly discouraged by matplotlib, you should instead use pyplot: from matplotlib import pyplot as plt plt.ylim(0, 100) #corresponding function for the x-axis plt.xlim(1, 1000)