Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting values from for loop  RSS feed

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my for loop I am getting 10 values,this values return type is double, I want to assign each values(1-10) to individual variable(Ex:d1 is:23.345,d2 is:45.988,d3 is:87.098....etc).Can any one help me how Can I assign this.



regards,
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use an array of ten doubles:

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi hill,

thanks for your reply


regards,
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi hill,

how to assign this 10 values to 10different double values.
Ex: double d1,d2,d3....
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
fred rosenberger
lowercase baba
Bartender
Posts: 12441
42
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to dynamically name your variables? i.e. if you have 10 doubles, you want variables named d1 through d10, but if you had 20 you'd want d1 through d20?

The short answer is - you can't. and there is no reason to. giving a variable a name is really only for the author's convenience. If they are being generated dynamically, the author will never see them, so they serve no point.

Seriously, use an array.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!