wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
function baz(): void {{ return 59; }} | function baz(): number {{ return 59; }} | Return type mismatch. | TypeScript |
97c = 10 | c97 = 10 | Variable cannot start with digit. | Python |
for (int i=0; i<73; i++) {{}} | for (int i=0; i<73; i++) {{}} | Correct. | Java |
if (x = 8) | if (x == 8) | Use ==. | C++ |
let bar: Int = 'hello' | let bar: String = 'hello' | Fix type. | Swift |
function render() {{ echo 'test'; }} | function render() {{ echo 'test'; }} | Correct. | PHP |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
data[31] | if data.indices.contains(31) {{ data[31] }} | Check index. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String val = 'world'; | String val = "world"; | Double quotes. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
random.sqrt(7) | import random
random.sqrt(7) | Import module first. | Python |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
baz | baz() | Add parentheses. | Kotlin |
fn process() -> i32 {{ 21 }} | fn process() -> i32 {{ 21 }} | Correct. | Rust |
if a = 19 then
print('hello')
end | if a == 19 then
print('hello')
end | Use ==. | Lua |
if item = 56: | if item == 56: | Use == for comparison. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print 'output' | print('output') | print needs parentheses. | Python |
id: info
id: test, | id: info
id: test | Remove comma. | YAML |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if b = 61 | if b == 61 | Use ==. | Ruby |
{{'id':8, 'age' 93}} | {{'id':8, 'age':93}} | Colon missing. | Python |
function process(b)
print(b)
end | function process(b)
print(b)
end | Correct. | Lua |
[28, 70, 81 | [28, 70, 81] | Close bracket. | Ruby |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if (item = 40) {{}} | if (item == 40) {{}} | Use ==. | Kotlin |
if data = 69 | if data == 69 | Use ==. | MATLAB |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
let count = 66; count += 1; | let mut count = 66; count += 1; | Need mut to modify. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
yield y | yield y | Correct yield. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
'message' + 40 | 'message' + 40.to_s | Convert int. | Ruby |
INSERT INTO items VALUES ('hello',61) | INSERT INTO items (age, role) VALUES ('hello',61); | Specify columns. | SQL |
let c = 88; | let c = 88; | Correct. | JavaScript |
[15, 61, 16 | [15, 61, 16] | Close bracket. | Python |
else
print('output') | else:
print('output') | Colon after else. | Python |
if c > 91
puts 'output' | if c > 91
puts 'output'
end | Add 'end'. | Ruby |
class Order {{ int foo; }}
obj.foo=5; | class Order {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
SELECT * FROM items WHRE name=32; | SELECT * FROM items WHERE name=32; | Fix WHERE. | SQL |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
if ($b = 84) {{}} | if ($b -eq 84) {{}} | Use -eq. | PowerShell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
var x int | var x int | Correct. | Go |
<person><desc>data</desc><desc>92</desc></person | <person><desc>data</desc><desc>92</desc></person> | Add closing >. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
for i=1,45 do print(i) end | for i=1,45 do print(i) end | Correct. | Lua |
if (a = 53) | if (a == 53) | Use ==. | R |
def bar
puts 'test'
end | def bar
puts 'test'
end | Correct. | Ruby |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
disp('message') | disp('message') | Correct. | MATLAB |
result = output | result = 'output' | Quote strings. | Python |
'83' + 72 | 83 + 72 | Avoid string coercion. | JavaScript |
local count = 28 | local count = 28 | Correct. | Lua |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
if (y = 95) | if (y == 95) | Use ==. | R |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'output' | print 'output'; | Add semicolon. | Perl |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
values[37] | if (length(values) >= 37) values[37] | Check length. | R |
if ($x = 32) | if ($x == 32) | Use ==. | Perl |
if foo = 70 then
print('hello')
end | if foo == 70 then
print('hello')
end | Use ==. | Lua |
switch(foo){{ case 30: break; }} | switch(foo){{ case 30: break; default: break; }} | Add default case. | Java |
let y = 'message' | let y = "message" | Double quotes. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if [ $count = 99 ]; then | if [ "$count" = 99 ]; then | Quote variable. | Shell |
foo | foo() | Add parentheses. | Swift |
assert result > 22 | assert result > 22 | Correct. | Python |
if (bar = 65) | if (bar == 65) | Use ==. | C++ |
int arr[93]; arr[93]=5; | int arr[93]; if(93<93){{}} else arr[93]=5; | Bounds check. | C++ |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for (x in values) | for (x of values) | for...in iterates keys. | JavaScript |
function baz(temp:string){{return temp;}} baz(71); | function baz(temp:string){{return temp;}} baz('result'); | Pass correct type. | TypeScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
class Person {{ int index; }}; | class Person {{ public: int index; }}; | Make public. | C++ |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
print 'hello' | print('hello') | print needs parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.