I am freshman in this sphere, so please help.
import pygal
line_chart = pygal.Line()
line_chart.title="Chart"
line_chart.x_labels = ['Jan', 'Feb', 'Mar', 'April', 'May']
print('Enter a type of social media: ')
a=input()
print('Enter 5 values of '+a,': ')
b=list(input())
line_chart.add(a, b)
line_chart.render_in_browser()
Exception has occurred: TypeError unsupported operand type(s) for -: 'str' and 'str' this error is appearing in front of line_chart.render_in_browser() this code
You are pushing str
type of data into your chart.
You have to convert your input
type. The line chard would work on int
, float
or decimal type for number.
import pygal
line_chart = pygal.Line()
line_chart.title="Chart"
line_chart.x_labels = ['Jan', 'Feb', 'Mar', 'April', 'May']
print('Enter a type of social media: ')
a=input()
print('Enter 5 values of '+a,': ')
b=map(int, input().split())
line_chart.add(a, list(b))
line_chart.render_in_browser()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.