[Tutor] Need help!! I am a new python user
Blake Winton
bwinton@tor.dhs.org
Fri, 20 Oct 2000 18:19:37 -0400
* Zakir Hussain <zakir@nortelnetworks.com> [001020 15:34]:
> tot_min = (`end_min`) - (`start_min`)
> TypeError: bad operand type(s) for -
>
> start_min = self.sessions[self.current_entry[5]]['start'][0][4]
> end_min = self.sessions[self.current_entry[5]]['end'][0][4]
>
> #start_min's value is 40
> #end_min's value is 50
That's not entirely true...
The actual values aren't 40 and 50, but "40", and "50".
You have two strings, which you can't subtract.
> Also if I try to add the velues it concatinates them
> e.g: end_min + start_min = 5040
This also makes sense, since "adding" two strings will concatenate
them.
What you _really_ want to do is convert them to integers.
Look up the atoi function in the String module.
Later,
Blake.
--
9:40pm up 52 days, 21:07, 2 users, load average: 0.02, 0.09, 0.07