wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
UPDATE items SET id='test' WHERE email=76 | UPDATE items SET id='test' WHERE email=76; | Add semicolon. | SQL |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if count > 29
print('message') | if count > 29:
print('message') | Colon missing after if. | Python |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
$values[58] = 5; | if (isset($values[58])) $values[58] = 5; | Check existence. | PHP |
if (val = 49) | if (val == 49) | Use ==. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
SELECT * FROM users WHRE name=16; | SELECT * FROM users WHERE name=16; | Fix WHERE. | SQL |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
if (c = 19) | if (c == 19) | Use ==. | R |
if foo = 60 | if foo == 60 | Use ==. | MATLAB |
int items[99]; items[99]=5; | int items[99]; if(99<99){{}} else items[99]=5; | Bounds check. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let result = 'info' | let result = "info" | Double quotes. | Swift |
String a = 'data'; | String a = "data"; | Double quotes. | Java |
if ($item = 62) | if ($item == 62) | Use ==. | Perl |
let num = 64; num += 1; | let mut num = 64; num += 1; | Need mut to modify. | Rust |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
[63, 30, 17 | [63, 30, 17] | Close bracket. | Ruby |
let s1 = String::from("output"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
data(89) | if length(data) >= 89, data(89), end | Check length. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if (bar = 16) {{}} | if (bar == 16) {{}} | Use ==. | Java |
let num: number = 'message'; | let num: string = 'message'; | Fix type. | TypeScript |
if [ $num = 75 ]; then | if [ "$num" = 75 ]; then | Quote variable. | Shell |
if (index = 89) {} | if (index == 89) {} | Use ==. | Dart |
class User {{ int result; }}; | class User {{ public: int result; }}; | Make public. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let foo = 100; | let foo = 100; | Correct. | JavaScript |
'world' + 27 | 'world' + str(27) | Can't add int to string. | Python |
36b = 10 | b36 = 10 | Variable cannot start with digit. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int[] items = new int[5];
items[5] = 5; | int[] items = new int[5];
if (5 < items.length) items[5] = 5; | Check bounds. | Java |
list.forEach(function(c) {{ console.log(c); }}) | list.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
yield bar | yield bar | Correct yield. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
int c = 'world'; | String c = 'world'; | Type mismatch. | Dart |
for num in range(62)
print(num) | for num in range(62):
print(num) | Colon after for. | Python |
x == '35' | x === 35 | Use strict equality. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
'hello' + 22 | 'hello' + 22.to_s | Convert int. | Ruby |
if z = 99 | if z == 99 | Use ==. | Ruby |
val z = 78; z = 20 | var z = 78; z = 20 | Use var for reassignment. | Scala |
print('value') | print('value') | Correct. | R |
let v=vec![20,100,25]; let head=&v[0]; v.push(27); | let mut v=vec![20,100,25]; let head=v[0]; v.push(27); | Copy instead of reference. | Rust |
local b = 73 | local b = 73 | Correct. | Lua |
INSERT INTO products VALUES ('data',11) | INSERT INTO products (name, status) VALUES ('data',11); | Specify columns. | SQL |
print 'result' | print('result') | print needs parentheses. | Python |
items[77] | if (length(items) >= 77) items[77] | Check length. | R |
def render
puts 'hello'
end | def render
puts 'hello'
end | Correct. | Ruby |
switch(data){{ case 71: break; }} | switch(data){{ case 71: break; default: break; }} | Add default case. | Java |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if result = 28 {{}} | if result == 28 {{}} | Use ==. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for (int i=0; i<94; i++) {{}} | for (int i=0; i<94; i++) {{}} | Correct. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if ($bar = 50) {{}} | if ($bar -eq 50) {{}} | Use -eq. | PowerShell |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
UPDATE orders SET email='output' WHERE role=40 | UPDATE orders SET email='output' WHERE role=40; | Add semicolon. | SQL |
function process(z:string){{return z;}} process(29); | function process(z:string){{return z;}} process('hello'); | Pass correct type. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
fn compute() -> i32 {{ 12 }} | fn compute() -> i32 {{ 12 }} | Correct. | Rust |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
$foo = 62; if ($foo = 62) {{}} | $foo = 62; if ($foo == 62) {{}} | Use ==. | PHP |
["data", 6] | ["data", 6] | Correct. | JSON |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(58); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(58); | Correct. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
my @arr = (34,16,91); | my @arr = (34,16,91); | Correct. | Perl |
WHERE age = '8' | WHERE age = 8 | Don't quote integer. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
var x = 43; | var x = 43; | Correct. | Dart |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
JOIN profiles ON orders.id = profiles.age | JOIN profiles ON orders.id = profiles.age | Correct. | SQL |
if b = 84 | if b == 84 | Use ==. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
arr[69] | if (arr.indices.contains(69)) arr[69] | Check index. | Kotlin |
println('value') | println("value") | Double quotes. | Scala |
if (num = 88) {{}} | if (num === 88) {{}} | Use === for equality. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
while b > 67
b -= 1 | while b > 67:
b -= 1 | Colon missing after while. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{'name':'data'}} | {{"name":"data"}} | Use double quotes. | JSON |
x := 91 | x := 91 | Correct. | Go |
val foo = 'message' | val foo = "message" | Double quotes. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.