mardi 28 juillet 2020

How come I can’t get a specific name? [closed]

What I am trying to do is get one specific name.

When it prints out and keep getting different random last names for the name that I choose from the first_class but don’t know how I can do that I thought by using the re module I could make it into a group and print it out the name that I wanted to choose but it hasn’t been working so far

EDIT

It is looked for a solution to get a pair of names out of the raw string and the list (first_class, second_class). The First attempt was to use regex library but this does not work.

import random
import re


first_class = (r"(Mary), (Sara) ,(Violet), Rob, joey, Jorge, Manny, Patty")

second_class = [" Perez" , " Valdiva", " Reys", " Diaz", " Walker", " Cortez", " Lopez", " Gonzalez", " Johnson"]


First_attendanc = (random.choice(first_class))
Second_attendanc = (random.choice(second_class))


names = (First_attendanc)
names_two = (Second_attendanc)

Here is where I feel like everything is in order for me to choose the name I want yet my code is not working?

print(re.match(first_class ,"Mary , Sara ,Violet, Rob, joey, Jorge, Manny, Patty")(raw_input("Choose name: " + names + names_two))).group(1)



Aucun commentaire:

Enregistrer un commentaire