{"id":35,"date":"2018-12-24T04:59:57","date_gmt":"2018-12-24T04:59:57","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=35"},"modified":"2018-12-24T04:59:57","modified_gmt":"2018-12-24T04:59:57","slug":"counting-the-number-of-words-and-number-of-lines-in-a-string","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2018\/12\/counting-the-number-of-words-and-number-of-lines-in-a-string\/","title":{"rendered":"Counting the number of words and number of lines in a string"},"content":{"rendered":"<pre>def word_line_count(s):\n    return(len(s.split()),len(s.splitlines()))\n\nmy_list = \"CSeries 275 MRJ 150\"\nprint(word_line_count(my_list)) \n#(4, 1)\n\n\nmy_list = \"CSeries 275\\n MRJ 150\"\nprint(word_line_count(my_list))\n#(4, 2)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>def word_line_count(s): return(len(s.split()),len(s.splitlines())) my_list = &#8220;CSeries 275 MRJ 150&#8221; print(word_line_count(my_list)) #(4, 1) my_list = &#8220;CSeries 275\\n MRJ 150&#8221; print(word_line_count(my_list)) #(4, 2)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[3],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-python","tag-python"],"modified_by":null,"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-z","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1874,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/06\/353-particle-swarm-optimization-using-python\/","url_meta":{"origin":35,"position":0},"title":"#353 Particle swarm optimization using python","author":"gantovnik","date":"2023-06-28","format":false,"excerpt":"","rel":"","context":"In &quot;optimization&quot;","block_context":{"text":"optimization","link":"https:\/\/gantovnik.com\/bio-tips\/category\/optimization\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6026,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/11\/449-filled-polygon-with-koch-snowflake-in-python\/","url_meta":{"origin":35,"position":1},"title":"#449 Filled polygon with Koch snowflake in python","author":"gantovnik","date":"2024-11-15","format":false,"excerpt":"import matplotlib.pyplot as plt import numpy as np import os def koch_snowflake(order, scale=10): # Return two lists x, y of point coordinates of the Koch snowflake. def _koch_snowflake_complex(order): if order == 0: # initial triangle angles = np.array([0, 120, 240]) + 90 return scale \/ np.sqrt(3) * np.exp(np.deg2rad(angles) * 1j)\u2026","rel":"","context":"In &quot;math&quot;","block_context":{"text":"math","link":"https:\/\/gantovnik.com\/bio-tips\/category\/math\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/11\/ex499.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/11\/ex499.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/11\/ex499.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/11\/ex499.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/11\/ex499.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":847,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/01\/150-optimization-with-a-module-in-python\/","url_meta":{"origin":35,"position":2},"title":"#150 Optimization with a module in python","author":"gantovnik","date":"2021-01-24","format":false,"excerpt":"#150 Optimization with a module in python ex150.py structure.py: Output:","rel":"","context":"In &quot;optimization&quot;","block_context":{"text":"optimization","link":"https:\/\/gantovnik.com\/bio-tips\/category\/optimization\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/01\/ex150-300x200.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1872,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/06\/352-optimization-using-genetic-algorithm-in-python\/","url_meta":{"origin":35,"position":3},"title":"#352 Optimization using Genetic Algorithm in python","author":"gantovnik","date":"2023-06-28","format":false,"excerpt":"","rel":"","context":"In &quot;genetic algorithm&quot;","block_context":{"text":"genetic algorithm","link":"https:\/\/gantovnik.com\/bio-tips\/category\/genetic-algorithm\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/06\/ga_history.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1746,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/01\/204-mandelbrot-fractal-using-python-2-2-2-2-2-2-2-2-2-2\/","url_meta":{"origin":35,"position":4},"title":"#331 Interpolation with Newton&#8217;s polynomial using python","author":"gantovnik","date":"2023-01-04","format":false,"excerpt":"interpolation.py ex331.py","rel":"","context":"In &quot;interpolation&quot;","block_context":{"text":"interpolation","link":"https:\/\/gantovnik.com\/bio-tips\/category\/interpolation\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/01\/ex331.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2203,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/05\/429-pattern-matching-with-regular-expressions-grouping-with-parentheses\/","url_meta":{"origin":35,"position":5},"title":"#429 Pattern matching with regular expressions: grouping with parentheses","author":"gantovnik","date":"2024-05-30","format":false,"excerpt":"Output:","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}