Need help asking for an input sentence

7 visualizaciones (últimos 30 días)
Alex Skantz
Alex Skantz el 21 de Oct. de 2021
Respondida: Akira Agata el 21 de Oct. de 2021
Hi, I need to ask the user to insert a sentence. I have
N=input('what is N?: ')
A=input('give me a sentence!: ');
Once I run the code and insert any word I get an error that says invalid expression. How can I stop the error from popping up? I will also be asking the sentence prompt to repeat until a certain word or phrase is typed.

Respuestas (1)

Akira Agata
Akira Agata el 21 de Oct. de 2021
To input a text, you should use 's' option, like:
N = input('what is N?: ')
A = input('give me a sentence!: ','s');

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by