How to make this program in python?

Georges Kayembe

I'm try to make this: your enter a word like this: Happy and than the program returns somethings like : yppaH or appHy.

The problem is that I get just one letter : y or H, etc..

import random
def myfunction():
    """change letter's position"""
    words = input("writte one word of your choice? : ")
    words = random.choice(words)
    print('E-G says : '+ words)
Ilya V. Schurov

You have to use sample, not choice.

import random
# it is better to have imports at the beginning of your file
def myfunction():
    """change letter's position"""
    word = input("writte one word of your choice? : ")
    new_letters = random.sample(word, len(word))
    # random.sample make a random sample (without returns)
    # we use len(word) as length of the sample
    # so effectively obtain shuffled letters
    # new_letters is a list, so we have to use "".join
    print('E-G says : '+ "".join(new_letters))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I make an EXE file from a Python program?

How To Make a Python Program Automatically Restart Itself

How to make an interactive program?

How to make a program that can be opened with a file? (python)

How do I make my python program to write a new file

How to make a proper name input program in python

How to make a one-window program with GTK, python and glade?

PYTHON: How to make a program to stop if some seconds have passed?

How do I make a Python Program demonstrating Zipf's Law?

How to make a python program measuring nanoseconds between keystroke dynamics?

How do I make a function run when a program finishes in Python?

How to make a new object while the program is running (Python, pygame)

How to make 'python' program command execute Python 3?

how do I make a python program write directly to the command line?

How do I make a password program in Python 3.4?

How to make python program ".py" executable?

how to make a python program using "while" to print at 0?

How to make globally callable python program?

How to make a program run at startup using python

How to make a python program that lists the positions and displays and error message if not found

How would I make this program two players in python?

How to make a program end on a blank line in python?

Python | How to make a program that calculates strings

How to make a word counter program using Python?

Any Ideas how to make a Python program that makes simple commands into the OS

How to make an on/off switch for a function in a python program?

How do you make a new variable while a program is running in python?

How to make any python program run standalone

how to make sign up and login program in python?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive