Mar-04-2018, 01:16 PM
I'm very beginner trying to learn to code and I'm stuck with this... I need to convert strings to integers (to use it in plots), but I want users to be able to define them as "letters".
Example from code:
..and now I got it working using "eval" - problem solved.
Example from code:
import matplotlib.pyplot as plt mon = 0 tue = 1 wen = 2 beg1 = input("Starting day? mon/tue/wen") peop1 = int(input("Number of people?")) course1=(beg1, peop1)For the first question, I would like user to be able to write e.g. "mon" and for the second e.g. "3" and then I would get course1 = (0, 3) and then plot it, but I get Value error to first question ("Could not convert string to float..."). Could anybody help me, what is wrong in code?
..and now I got it working using "eval" - problem solved.