# Replace number with given numbers

**URL:** <https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431>\
**Category:** Grasshopper\
**Created:** [January 19, 2018, 3:44pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431 "2018-01-19T15:44:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Foley](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_foley/32/42923_2.png) [@James\_Foley](https://discourse.mcneel.com/u/James_Foley)\
**Post date:** [January 19, 2018, 3:44pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/1 "2018-01-19T15:44:05Z")

</div>

Hey

I have list of number which consists of

5  
61  
7  
74  
86  
95  
9  
99

This list will contain 100’s of these values.  
I need to replace them with.

1.0  
1.2  
1.4  
1.48  
1.72  
1.8  
1.9  
1.98

So

5 = 1.0  
61 = 1.2  
7 = 1.4  
74 = 1.48  
86 = 1.72  
95 = 1.8  
9 = 1.9  
99 = 1.98

Number  
5  
and  
7  
where meant to be 50 and 70 but I derived them from a decimal place and grasshopper changes  
0.50 to 0.5  
0.70 to 0.7  
0.90 to 0.9  
Thanks.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [January 19, 2018, 4:56pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/2 "2018-01-19T16:56:30Z")

</div>

There seems to be a perfectly linear relationship between your input and your output, which means you can just run the values through an expression rather than try difficult find/replace logic. Would that work?

---

<div class="post-metadata">

**Author:** ![James\_Foley](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_foley/32/42923_2.png) [@James\_Foley](https://discourse.mcneel.com/u/James_Foley)\
**Post date:** [January 19, 2018, 5:07pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/3 "2018-01-19T17:07:52Z")

</div>

I think it might work but I’m new to grasshopper and I don’t know how to construct anything, especially expression which I cannot even copy.

 ![test 2](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/3/9/398a8fb4e3600654b6e7dd2807ed1b2b4e740de7.jpg)

I solved it like this ;/

but it still doesn’t work ;/?

This is my structure

 ![test 3](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/b/c/bc29ebe437f9e32bede476b8da177ef8bbd26124.jpg)

I would have though it would create shapes with 1’s first (at the bottom) and then go up but it seems like it chooses values randomly. Why?

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [January 19, 2018, 5:26pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/4 "2018-01-19T17:26:41Z")

</div>

> [@James\_Foley](#):
>
> Why?

I can’t tell from looking at images. Please simplify your file as much as possible and upload it [in accordance with this](https://discourse.mcneel.com/t/how-to-ask-effective-questions/50034).

If you have a list of numbers that need to become a different list of numbers and there’s an equation for converting them, that’ll be the easiest solution. But I need to actually have the data you have otherwise I can’t tell what solution would work.

---

<div class="post-metadata">

**Author:** ![James\_Foley](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_foley/32/42923_2.png) [@James\_Foley](https://discourse.mcneel.com/u/James_Foley)\
**Post date:** [January 19, 2018, 5:44pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/5 "2018-01-19T17:44:15Z")

</div>

[test 5.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/e/f/ef370b785286210c01c41786d4aa657f7711e452.gh) (14.1 KB)

Geometry does not follow the order of the panel.

First value is 1.4 but grasshopper will generate 1  
Second number is 1.4 but grasshopper will generate 1.2  
I want it to follow the order shown in the panel.  
Really confusing.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [January 19, 2018, 11:02pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/6 "2018-01-19T23:02:04Z")

</div>

You mentioned that `5` and `7` were meant to be `50` and `70` but that they were changed by Grasshopper. Does that mean that you have actual numbers somewhere before you turn them into text?

---

<div class="post-metadata">

**Author:** ![jeff\_hammond](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jeff_hammond/32/768846_2.png) [@jeff\_hammond](https://discourse.mcneel.com/u/jeff_hammond)\
**Post date:** [January 20, 2018, 1:12am UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/7 "2018-01-20T01:12:01Z")

</div>

![03 PM](https://global.discourse-cdn.com/mcneel/original/3X/4/4/44fa516b86d1c1425f93a0404caa22f0d0e2c7aa.png)

---

<div class="post-metadata">

**Author:** ![jeff\_hammond](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jeff_hammond/32/768846_2.png) [@jeff\_hammond](https://discourse.mcneel.com/u/jeff_hammond)\
**Post date:** [January 20, 2018, 1:51am UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/8 "2018-01-20T01:51:13Z")

</div>

or:

 ![44 PM](https://global.discourse-cdn.com/mcneel/original/3X/a/1/a1f97d323602d821fb0b7a1cbb7f1a03007573af.png)

: )

---

<div class="post-metadata">

**Author:** ![James\_Foley](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_foley/32/42923_2.png) [@James\_Foley](https://discourse.mcneel.com/u/James_Foley)\
**Post date:** [January 21, 2018, 8:01pm UTC](https://discourse.mcneel.com/t/replace-number-with-given-numbers/53431/9 "2018-01-21T20:01:06Z")

</div>

No they were always fractions. But I’m really worried about my second problem. Which is geometry generation. Grasshopper takes one number from start one from the middle and one from the end it groups them but nowhere I defined the grouping. The height of the structures should follow the list from start to end.
