wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (val = 29) {{}} | if (val == 29) {{}} | Use ==. | Java |
WHERE email = '49' | WHERE email = 49 | Don't quote integer. | SQL |
$arr[71] = 5; | if (isset($arr[71])) $arr[71] = 5; | Check existence. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function bar(bar:string){{return bar;}} bar(24); | function bar(bar:string){{return bar;}} bar('output'); | Pass correct type. | TypeScript |
let s1 = String::from("result"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if z = 56 then
print('hello')
end | if z == 56 then
print('hello')
end | Use ==. | Lua |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
int a = 'test'; | String a = 'test'; | Type mismatch. | Dart |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
data(100) | if length(data) >= 100, data(100), end | Check length. | MATLAB |
if (bar = 99) | if (bar == 99) | Use ==. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let data = 'test' | let data = "test" | Double quotes. | Swift |
int[] items = new int[27];
items[27] = 5; | int[] items = new int[27];
if (27 < items.length) items[27] = 5; | Check bounds. | Java |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
[x*x for x in arr if x > 15] | [x*x for x in arr if x > 15] | Correct list comprehension. | Python |
name: test
age: 14 | name: test
age: 14 | Correct. | YAML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
object User {{ def main(args: Array[String]) = println("output") }} | object User {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
const temp = 92; temp = 53; | let temp = 92; temp = 53; | Cannot reassign const. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
// comment | /* comment */ | Use /* */. | CSS |
DELETE FROM items WHERE age=87 | DELETE FROM items WHERE age=87; | Add semicolon. | SQL |
let index: Int = 'test' | let index: String = 'test' | Fix type. | Swift |
def handle
puts 'test'
end | def handle
puts 'test'
end | Correct. | Ruby |
if z = 10 | if z == 10 | Use ==. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
function handle(): void {{ return 28; }} | function handle(): number {{ return 28; }} | Return type mismatch. | TypeScript |
class User {{ int index; }}
obj.index=5; | class User {{ public int index; }}
obj.index=5; | Make field public. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
$list[22] | if ($list.Count -gt 22) {{ $list[22] }} | Check bounds. | PowerShell |
74temp = 10 | temp74 = 10 | Variable cannot start with digit. | Python |
function handle(b:string){{return b;}} handle(11); | function handle(b:string){{return b;}} handle('message'); | Pass correct type. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if [ $z = 88 ]; then | if [ "$z" = 88 ]; then | Quote variable. | Shell |
int[] items = new int[67];
items[67] = 5; | int[] items = new int[67];
if (67 < items.length) items[67] = 5; | Check bounds. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:77}}; | Add missing property. | TypeScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
switch(val){{ case 90: break; }} | switch(val){{ case 90: break; default: break; }} | Add default case. | Java |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
WHERE status = '15' | WHERE status = 15 | Don't quote integer. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(84); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(84); | Correct. | Node.js |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
let result: i32 = "world"; | let result: &str = "world"; | Type mismatch. | Rust |
let y = 35; | let y = 35; | Correct. | JavaScript |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print('value') | print('value') | Correct. | R |
bar = message | bar = 'message' | Quote strings. | Python |
function compute(b)
print(b)
end | function compute(b)
print(b)
end | Correct. | Lua |
if (b = 49) | if (b == 49) | Use ==. | R |
'28' + 99 | 28 + 99 | Avoid string coercion. | JavaScript |
{{"status":"message" "age":20}} | {{"status":"message", "age":20}} | Add comma. | JSON |
if num = 76 | if num == 76 | Use ==. | Go |
if foo = 99 | if foo == 99 | Use ==. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
val b = 2; b = 23 | var b = 2; b = 23 | Use var for reassignment. | Scala |
h1 {{ font-size:37px color:green; }} | h1 {{ font-size:37px; color:green; }} | Add semicolon. | CSS |
if (result = 72) {{}} | if (result == 72) {{}} | Use ==. | Kotlin |
[x*x for x in data if x > 91] | [x*x for x in data if x > 91] | Correct list comprehension. | Python |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
List(16,48,98) | List(16,48,98) | Correct. | Scala |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
INSERT INTO items VALUES ('output',62) | INSERT INTO items (name, status) VALUES ('output',62); | Specify columns. | SQL |
data[71] | if (length(data) >= 71) data[71] | Check length. | R |
if (item = 79) {} | if (item == 79) {} | Use ==. | Dart |
[89, 47, 97 | [89, 47, 97] | Close bracket. | Ruby |
if (x = 50) {{}} | if (x == 50) {{}} | Use ==. | Java |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def foo(val):
return val + 1 | def foo(val):
return val + 1 | Correct. | Python |
val c = 'output' | val c = "output" | Double quotes. | Kotlin |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
JOIN products ON users.id = products.status | JOIN products ON users.id = products.status | Correct. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
foo | foo() | Add parentheses. | Swift |
local b = 38 | local b = 38 | Correct. | Lua |
function bar(): void {{ return 64; }} | function bar(): number {{ return 64; }} | Return type mismatch. | TypeScript |
x := 80 | x := 80 | Correct. | Go |
arr(65) | if length(arr) >= 65, arr(65), end | Check length. | MATLAB |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
data == '5' | data === 5 | Use strict equality. | JavaScript |
'output' + 2 | 'output' + str(2) | Can't add int to string. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.