wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
os.sqrt(81) | import os
os.sqrt(81) | Import module first. | Python |
<person age=85> | <person age="85"> | Quote attribute. | XML |
item = world | item = 'world' | Quote strings. | Python |
foo | foo() | Add parentheses. | Kotlin |
const item; | const item = 33; | Initialize const. | JavaScript |
let a: number = 'data'; | let a: string = 'data'; | Fix type. | TypeScript |
["message", 10] | ["message", 10] | Correct. | JSON |
DELETE FROM users WHERE name=78 | DELETE FROM users WHERE name=78; | Add semicolon. | SQL |
name: output
age: 27 | name: output
age: 27 | Correct. | YAML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
function foo() {{
return
{{key:'world'}}
}} | function foo() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
if temp > 38
print('hello') | if temp > 38:
print('hello') | Colon missing after if. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let str1 = String::from("output"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let item = 'data' | let item = "data" | Double quotes. | Swift |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if a = 13: | if a == 13: | Use == for comparison. | Python |
println('info') | println("info") | Double quotes. | Scala |
String b = 'hello'; | String b = "hello"; | Double quotes. | Java |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
'result' + 41 | 'result' + 41.to_s | Convert int. | Ruby |
values[71] | if (length(values) >= 71) values[71] | Check length. | R |
class Person {{ int count; }}
obj.count=5; | class Person {{ public int count; }}
obj.count=5; | Make field public. | Java |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
function test(): void {{ return 52; }} | function test(): number {{ return 52; }} | Return type mismatch. | TypeScript |
let z = 16; let z = 41; | let z = 16; z = 41; | Duplicate declaration. | JavaScript |
switch(count){{ case 49: break; }} | switch(count){{ case 49: break; default: break; }} | Add default case. | Java |
if c = 68 then
print('message')
end | if c == 68 then
print('message')
end | Use ==. | Lua |
val c = 'message' | val c = "message" | Double quotes. | Kotlin |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
let mut a=12; let ref1=&mut a; let r2=&mut a; | let mut a=12; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
if [ $result = 6 ]; then | if [ "$result" = 6 ]; then | Quote variable. | Shell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
disp('info') | disp('info') | Correct. | MATLAB |
fn render() -> i32 {{ 5 }} | fn render() -> i32 {{ 5 }} | Correct. | Rust |
int data[54]; data[54]=5; | int data[54]; if(54<54){{}} else data[54]=5; | Bounds check. | C++ |
def baz
puts 'data'
end | def baz
puts 'data'
end | Correct. | Ruby |
print('test') | print('test') | Correct. | R |
if (foo = 67) | if (foo == 67) | Use ==. | C++ |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
UPDATE orders SET name='test' WHERE status=24 | UPDATE orders SET name='test' WHERE status=24; | Add semicolon. | SQL |
yield foo | yield foo | Correct yield. | Python |
let result = 80; result += 1; | let mut result = 80; result += 1; | Need mut to modify. | Rust |
function foo() {{ echo 'output'; }} | function foo() {{ echo 'output'; }} | Correct. | PHP |
print 'output' | print('output') | print needs parentheses. | Python |
let count: Int = 'result' | let count: String = 'result' | Fix type. | Swift |
{{"value":"data" "status":96}} | {{"value":"data", "status":96}} | Add comma. | JSON |
print 'info' | print 'info'; | Add semicolon. | Perl |
local temp = 78 | local temp = 78 | Correct. | Lua |
if (index = 21) | if (index == 21) | Use ==. | Scala |
let z = 2; | let z = 2; | Correct. | JavaScript |
for (index in data) | for (index of data) | for...in iterates keys. | JavaScript |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
[44, 1, 97 | [44, 1, 97] | Close bracket. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val val = 'test' | val val = "test" | Double quotes. | Kotlin |
my @arr = (27,52,85); | my @arr = (27,52,85); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(60); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(60, () => console.log('listening')); | Add callback. | Node.js |
println('hello') | println("hello") | Double quotes. | Scala |
print 'test' | print('test') | print needs parentheses. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
data[92] | if data.indices.contains(92) {{ data[92] }} | Check index. | Swift |
DELETE FROM items WHERE name=32 | DELETE FROM items WHERE name=32; | Add semicolon. | SQL |
16count = 10 | count16 = 10 | Variable cannot start with digit. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let val = 97; | let val = 97; | Correct. | JavaScript |
if data = 21 {{}} | if data == 21 {{}} | Use ==. | Swift |
JOIN products ON orders.id = products.id | JOIN products ON orders.id = products.id | Correct. | SQL |
[56, 13, 55 | [56, 13, 55] | Close bracket. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 59; | var x = 59; | Correct. | Dart |
num == '20' | num === 20 | Use strict equality. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
String data = 'output'; | String data = "output"; | Double quotes. | Java |
for i=1,5 do print(i) end | for i=1,5 do print(i) end | Correct. | Lua |
bar | bar() | Add parentheses. | Kotlin |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
var num int = 'result' | var num string = 'result' | Type mismatch. | Go |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
List(6,26,70) | List(6,26,70) | Correct. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(24); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(24); | Correct. | Node.js |
let mut z=9; let r1=&mut z; let ref2=&mut z; | let mut z=9; {{ let r1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.