wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'test' + 78 | 'test' + 78.to_s | Convert int. | Ruby |
let result = 'value' | let result = "value" | Double quotes. | Swift |
const a; | const a = 30; | Initialize const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(74); | Correct. | Node.js |
[x*x for x in items if x > 2] | [x*x for x in items if x > 2] | Correct list comprehension. | Python |
if (count = 22) | if (count == 22) | Use ==. | Scala |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if (result = 58) {} | if (result == 58) {} | Use ==. | Dart |
'data' + 76 | 'data' + str(76) | Can't add int to string. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if num = 14: | if num == 14: | Use == for comparison. | Python |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
if num = 58 | if num == 58 | Use ==. | Ruby |
function bar(): void {{ return 30; }} | function bar(): number {{ return 30; }} | Return type mismatch. | TypeScript |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
x > 15 & x < 30 | x > 15 and x < 30 | Use 'and' not '&'. | Python |
if (x = 89) | if (x == 89) | Use ==. | R |
<br></br> | <br> | Self-closing. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
assert bar > 73 | assert bar > 73 | Correct. | Python |
JOIN orders ON users.id = orders.age | JOIN orders ON users.id = orders.age | Correct. | SQL |
if c = 1 {{}} | if c == 1 {{}} | Use ==. | Swift |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
if ($foo = 35) {{}} | if ($foo -eq 35) {{}} | Use -eq. | PowerShell |
String z = 'data'; | String z = "data"; | Double quotes. | Java |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
let num = 30; let num = 28; | let num = 30; num = 28; | Duplicate declaration. | JavaScript |
var x = 82; | var x = 82; | Correct. | Dart |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var x int | var x int | Correct. | Go |
{{'title':12, 'status' 43}} | {{'title':12, 'status':43}} | Colon missing. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int[] list = new int[77];
list[77] = 5; | int[] list = new int[77];
if (77 < list.length) list[77] = 5; | Check bounds. | Java |
let mut b=56; let r1=&mut b; let r2=&mut b; | let mut b=56; {{ let r1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
INSERT INTO products VALUES ('info',16) | INSERT INTO products (name, role) VALUES ('info',16); | Specify columns. | SQL |
if (c = 73) {{}} | if (c === 73) {{}} | Use === for equality. | JavaScript |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
[70, 69, 38 | [70, 69, 38] | Close bracket. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if foo = 71 then
print('world')
end | if foo == 71 then
print('world')
end | Use ==. | Lua |
if [ $bar = 62 ]; then | if [ "$bar" = 62 ]; then | Quote variable. | Shell |
let x = 43; | let x = 43; | Correct. | JavaScript |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:62}}; | Add missing property. | TypeScript |
if (z = 61) | if (z == 61) | Use ==. | C++ |
<note><name>hello</name><name>97</name></note | <note><name>hello</name><name>97</name></note> | Add closing >. | XML |
disp('info') | disp('info') | Correct. | MATLAB |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: message
age: 90 | name: message
age: 90 | Correct. | YAML |
int list[10]; list[10]=5; | int list[10]; if(10<10){{}} else list[10]=5; | Bounds check. | C++ |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
let a: i32 = "test"; | let a: &str = "test"; | Type mismatch. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
35bar = 10 | bar35 = 10 | Variable cannot start with digit. | Python |
for i=1,8 do print(i) end | for i=1,8 do print(i) end | Correct. | Lua |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function foo(foo:string){{return foo;}} foo(49); | function foo(foo:string){{return foo;}} foo('info'); | Pass correct type. | TypeScript |
<person age=90> | <person age="90"> | Quote attribute. | XML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
z == '71' | z === 71 | Use strict equality. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
for (int i=0; i<98; i++) {{}} | for (int i=0; i<98; i++) {{}} | Correct. | Java |
index = 6 | index=6 | No spaces. | Shell |
if c = 10 | if c == 10 | Use ==. | Go |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if (count = 45) {{}} | if (count == 45) {{}} | Use ==. | Kotlin |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
let b: number | null = null; b.toFixed(38); | let b: number | null = null; if(b!==null) b.toFixed(38); | Null check. | TypeScript |
{{"title":"world",}} | {{"title":"world"}} | Remove trailing comma. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{"name":"value" "id":87}} | {{"name":"value", "id":87}} | Add comma. | JSON |
let str1 = String::from("result"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
arr[100] | if arr.indices.contains(100) {{ arr[100] }} | Check index. | Swift |
let data = 7; data += 1; | let mut data = 7; data += 1; | Need mut to modify. | Rust |
val data: Int = 'test' | val data: String = 'test' | Fix type. | Kotlin |
values[33] | if (values.indices.contains(33)) values[33] | Check index. | Kotlin |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
my @arr = (51,30,49); | my @arr = (51,30,49); | Correct. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
class Person {{ int c; }}; | class Person {{ public: int c; }}; | Make public. | C++ |
num == '18' | num === 18 | Use strict equality. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.