Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
May 16th, 2013, 08:09 AM
 Filip.V
Registered User

Join Date: May 2013
Posts: 19
Time spent in forums: 2 h 8 m
Reputation Power: 0
How to give a value to numbers of a string?

Every string contains different numbers but this is an example of one.

(number1,number2,number3,number4,number5,number6,) = [2 ,1 ,7 ,30,39,51,]

I can print the number1 to number6 separated but I can not calculate with them because they have the value 0.
How can I calculate with their real value?

Thanks

#2
May 16th, 2013, 08:24 AM
 dariyoosh
Contributing User

Join Date: Nov 2012
Location: Iran
Posts: 148
Time spent in forums: 2 Days 15 h 7 m 17 sec
Reputation Power: 139
Quote:
 Originally Posted by Filip.V Every string contains different numbers but this is an example of one.
I don't see any string here in your question. You just initialize six integer numbers
python Code:
 Original - python Code
```(number1,number2,number3,number4,number5,number6,) = [2 ,1 ,7 ,30,39,51,]
```

Quote:
 Originally Posted by Filip.V I can print the number1 to number6 separated but I can not calculate with them because they have the value 0.
I don't understand what do you mean by 'They have the value 0'
python Code:
 Original - python Code
``` >>> (number1,number2,number3,number4,number5,number6,) = [2 ,1 ,7 ,30,39,51,]>>> number12>>> number21>>> number37>>> number430>>> number539>>> number651>>> (number1 + number6) * number41590>>> type(number1)<type 'int'>>>>
```
__________________
Regards,
Dariyoosh

#3
May 16th, 2013, 02:10 PM
 Filip.V
Registered User

Join Date: May 2013
Posts: 19
Time spent in forums: 2 h 8 m
Reputation Power: 0
I did something wrong but now I can calculate with it.Thanks

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > How to give a value to numbers of a string?