# Python definition function and for range() loop

I have a defined function:

``````def micronToStep(v):
#approximately 62nm/step
return round((v * 1000)/62)
``````

And the command `for range()` loop:

``````xyStep = 5
xRange = 400

for x in range(-micronToStep(xRange/2), micronToStep(xRange/2) - micronToStep(xyStep), micronToStep(xyStep))
``````

For `xyStep = 5`, `xRange = 400` the command: `len(range(-micronToStep(xRange/2), micronToStep(xRange/2) - micronToStep(xyStep), micronToStep(xyStep)))` returns `79`, which not exceed the limit `xRange/xyStep = 80`.

But for `xyStep = 1`, `xRange = 400` the `len(range())` function returns incorrect value `403` instead of value less or equal to `xRange/xyStep = 400`.

I think the problem lies in `micronToStep()` function.

How to correct this, that `for range()` loop would not exceed the limit of xRange/xyStep by number of iterations?
{"ft_lang_label":"__label__en","ft_lang_prob":0.5325236,"math_prob":0.97577536,"size":780,"snap":"2023-40-2023-50","text_gpt3_token_len":238,"char_repetition_ratio":0.22938144,"word_repetition_ratio":0.0,"special_character_ratio":0.28076923,"punctuation_ratio":0.11678832,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9936353,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-01T11:18:58Z\",\"WARC-Record-ID\":\"<urn:uuid:c4932ffd-eb3b-49ba-99c6-108e97ef08e8>\",\"Content-Length\":\"13279\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d6806197-33cd-4e4c-8473-0ece969482e6>\",\"WARC-Concurrent-To\":\"<urn:uuid:8ad1099e-87e3-4a9a-96fa-1dd5f33bcc31>\",\"WARC-IP-Address\":\"104.21.28.46\",\"WARC-Target-URI\":\"https://techqa.club/v/q/python-definition-function-and-for-range-loop-76341136\",\"WARC-Payload-Digest\":\"sha1:UI6T6KHNYFUVJXLFV2THYTTSVDWUPTBD\",\"WARC-Block-Digest\":\"sha1:BYNPTTZE4T4FLX2RHSOQX6KMM552QX5C\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510888.64_warc_CC-MAIN-20231001105617-20231001135617-00662.warc.gz\"}"}