Poetry with Poems inLoveLike

Poetic in Nature

EFT is Free SHA2-512 SHA3-512

How_to_shuffle_your_name_in_Python_3.py

Author: Nathaniel Steven Henry Brown
Started: June 22, 2021
Last Edited: August 30, 2021
#!/usr/bin/env python3
# (copyright) Nathaniel Steven Henry Brown
# Sources:
# https://docs.python.org/3/library/random.html
# https://www.geeksforgeeks.org/how-to-use-sys-argv-in-python/
# https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
# Usage:
# ./How_to_shuffle_your_name_in_Python_3.py Nathaniel Steven Henry Brown
import sys
import random

name = ''
n = len(sys.argv)

for i in range(1, n):
    name = name + sys.argv[i] + " "

name_as_list = list(name.strip())
random.shuffle(name_as_list)
name_shuffled = "".join(name_as_list)
print(name_shuffled.strip().lower().title())
Characters: 654
Lines: 21
Words: 62

Views: 362

Changes Made

Revision #4
Body
5a6
> # https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
Revision #3
Body
17c17
< name_as_list = list(name)
---
> name_as_list = list(name.strip())
20c20
< print(name_shuffled)
---
> print(name_shuffled.strip().lower().title())
Revision #2
Body
7c7
< # ./shuffle_name.py Nathaniel Steven Henry Brown
---
> # ./How_to_shuffle_your_name_in_Python_3.py Nathaniel Steven Henry Brown
Revision #1
Body
6c6,7
<
---
> # Usage:
> # ./shuffle_name.py Nathaniel Steven Henry Brown