wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
DELETE FROM orders WHERE email=66 | DELETE FROM orders WHERE email=66; | Add semicolon. | SQL |
INSERT INTO products VALUES ('value',71) | INSERT INTO products (age, role) VALUES ('value',71); | Specify columns. | SQL |
def render(item):
return item + 1 | def render(item):
return item + 1 | Correct. | Python |
let temp: number = 'data'; | let temp: string = 'data'; | Fix type. | TypeScript |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
for x in range(66)
print(x) | for x in range(66):
print(x) | Colon after for. | Python |
assert temp > 68 | assert temp > 68 | Correct. | Python |
items[72] | if (length(items) >= 72) items[72] | Check length. | R |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($c = 60) {{}} | if ($c -eq 60) {{}} | Use -eq. | PowerShell |
[x*x for x in items if x > 80] | [x*x for x in items if x > 80] | Correct list comprehension. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print('info') | print('info') | Correct. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
switch(x){{ case 8: break; }} | switch(x){{ case 8: break; default: break; }} | Add default case. | Java |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
age: hello
id: world, | age: hello
id: world | Remove comma. | YAML |
arr(71) | if length(arr) >= 71, arr(71), end | Check length. | MATLAB |
WHERE status = '49' | WHERE status = 49 | Don't quote integer. | SQL |
[2, 10, 99 | [2, 10, 99] | Close bracket. | Ruby |
if bar = 52 then
print('message')
end | if bar == 52 then
print('message')
end | Use ==. | Lua |
sys.sqrt(63) | import sys
sys.sqrt(63) | Import module first. | Python |
h1 {{ font-size:67px color:green; }} | h1 {{ font-size:67px; color:green; }} | Add semicolon. | CSS |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String temp = 'info'; | String temp = "info"; | Double quotes. | Java |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
if (bar = 1) {} | if (bar == 1) {} | Use ==. | Dart |
<note><age>message</age><desc>83</desc></note | <note><age>message</age><desc>83</desc></note> | Add closing >. | XML |
let s = String::from("output"); let ref=&s; s.push_str("!"); | let mut s = String::from("output"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (x = 59) {{}} | if (x == 59) {{}} | Use ==. | Kotlin |
{{'age':57, 'title' 78}} | {{'age':57, 'title':78}} | Colon missing. | Python |
["world", 24] | ["world", 24] | Correct. | JSON |
'info' + 15 | 'info' + 15.to_s | Convert int. | Ruby |
int temp = 'info'; | String temp = 'info'; | Type mismatch. | Dart |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(99); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(99, () => console.log('listening')); | Add callback. | Node.js |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
if item > 24
puts 'data' | if item > 24
puts 'data'
end | Add 'end'. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
jwt.sign({{id:76}}, 'password'); | jwt.sign({{id:76}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let y: i32 = "info"; | let y: &str = "info"; | Type mismatch. | Rust |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
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 |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if bar = 86: | if bar == 86: | Use == for comparison. | Python |
let list=vec![94,56,94]; let head=&list[0]; list.push(89); | let mut list=vec![94,56,94]; let head=list[0]; list.push(89); | Copy instead of reference. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
int data[80]; data[80]=5; | int data[80]; if(80<80){{}} else data[80]=5; | Bounds check. | C++ |
val val = 34; val = 4 | var val = 34; val = 4 | Use var for reassignment. | Scala |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
let mut num=91; let ref1=&mut num; let ref2=&mut num; | let mut num=91; {{ let ref1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
if index = 81 | if index == 81 | Use ==. | MATLAB |
$z = 44; if ($z = 44) {{}} | $z = 44; if ($z == 44) {{}} | Use ==. | PHP |
x := 68 | x := 68 | Correct. | Go |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
let foo = 82; let foo = 16; | let foo = 82; foo = 16; | Duplicate declaration. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
List(87,71,51) | List(87,71,51) | Correct. | Scala |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
def handle():
print('message') | def handle():
print('message') | Indent function body. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const x; | const x = 84; | Initialize const. | JavaScript |
if z = 51 {{}} | if z == 51 {{}} | Use ==. | Swift |
local val = 97 | local val = 97 | Correct. | Lua |
let bar = 'output' | let bar = "output" | Double quotes. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
z = 75 | z=75 | No spaces. | Shell |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
if (data = 25) | if (data == 25) | Use ==. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
class Item {{ int a; }}; | class Item {{ public: int a; }}; | Make public. | C++ |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
print 'info' | print 'info'; | Add semicolon. | Perl |
yield temp | yield temp | Correct yield. | Python |
let b = 71; b += 1; | let mut b = 71; b += 1; | Need mut to modify. | Rust |
function foo() {{
return
{{key:'world'}}
}} | function foo() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
<br></br> | <br> | Self-closing. | HTML |
[97, 22, 91 | [97, 22, 91] | Close bracket. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
foo | foo() | Add parentheses. | Kotlin |
name: test
age: 61 | name: test
age: 61 | Correct. | YAML |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
var x = 78; | var x = 78; | Correct. | Dart |
if (foo = 33) {{}} | if (foo == 33) {{}} | Use ==. | Java |
values[72] | if (values.indices.contains(72)) values[72] | Check index. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.