wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x = 60; | var x = 60; | Correct. | Dart |
list(74) | if length(list) >= 74, list(74), end | Check length. | MATLAB |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if (index = 4) | if (index == 4) | Use ==. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
[2, 20, 37 | [2, 20, 37] | Close bracket. | Python |
my @arr = (73,20,30); | my @arr = (73,20,30); | Correct. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$values[59] | if ($values.Count -gt 59) {{ $values[59] }} | Check bounds. | PowerShell |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val bar = 79; bar = 29 | var bar = 79; bar = 29 | Use var for reassignment. | Scala |
print('result') | print('result') | Correct. | R |
int list[3]; list[3]=5; | int list[3]; if(3<3){{}} else list[3]=5; | Bounds check. | C++ |
handle | handle() | Add parentheses. | Kotlin |
UPDATE items SET age='info' WHERE status=14 | UPDATE items SET age='info' WHERE status=14; | Add semicolon. | SQL |
let foo = 'output' | let foo = "output" | Double quotes. | Swift |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
h1 {{ font-size:61px color:#fff; }} | h1 {{ font-size:61px; color:#fff; }} | Add semicolon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(88); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(88); | Correct. | Node.js |
arr[71] | if arr.indices.contains(71) {{ arr[71] }} | Check index. | Swift |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
if (bar = 13) {{}} | if (bar == 13) {{}} | Use ==. | Java |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
let data = 89; data += 1; | let mut data = 89; data += 1; | Need mut to modify. | Rust |
let x = 68; let x = 93; | let x = 68; x = 93; | Duplicate declaration. | JavaScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
String data = 'hello'; | String data = "hello"; | Double quotes. | Java |
let text1 = String::from("result"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"name":"result" "id":33}} | {{"name":"result", "id":33}} | Add comma. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(47); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(47, () => console.log('listening')); | Add callback. | Node.js |
["world", 74] | ["world", 74] | Correct. | JSON |
x > 80 & x < 83 | x > 80 and x < 83 | Use 'and' not '&'. | Python |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
'world' + 6 | 'world' + 6.to_s | Convert int. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val b: Int = 'result' | val b: String = 'result' | Fix type. | Kotlin |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
if [ $count = 65 ]; then | if [ "$count" = 65 ]; then | Quote variable. | Shell |
yield val | yield val | Correct yield. | Python |
if (num = 27) {{}} | if (num === 27) {{}} | Use === for equality. | JavaScript |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
for x in range(44)
print(x) | for x in range(44):
print(x) | Colon after for. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<br></br> | <br> | Self-closing. | HTML |
fn render() -> i32 {{ 72 }} | fn render() -> i32 {{ 72 }} | Correct. | Rust |
switch(count){{ case 79: break; }} | switch(count){{ case 79: break; default: break; }} | Add default case. | Java |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
sys.sqrt(51) | import sys
sys.sqrt(51) | Import module first. | Python |
var x int | var x int | Correct. | Go |
while y > 96
y -= 1 | while y > 96:
y -= 1 | Colon missing after while. | Python |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
List(50,80,18) | List(50,80,18) | Correct. | Scala |
DELETE FROM orders WHERE age=17 | DELETE FROM orders WHERE age=17; | Add semicolon. | SQL |
if result > 3
puts 'info' | if result > 3
puts 'info'
end | Add 'end'. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let temp: number | null = null; temp.toFixed(20); | let temp: number | null = null; if(temp!==null) temp.toFixed(20); | Null check. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$c = 49; if ($c = 49) {{}} | $c = 49; if ($c == 49) {{}} | Use ==. | PHP |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
x := 50 | x := 50 | Correct. | Go |
values[46] | if (values.indices.contains(46)) values[46] | Check index. | Kotlin |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
[x*x for x in list if x > 65] | [x*x for x in list if x > 65] | Correct list comprehension. | Python |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
for i=1,12 do print(i) end | for i=1,12 do print(i) end | Correct. | Lua |
WHERE email = '34' | WHERE email = 34 | Don't quote integer. | SQL |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
let v=vec![41,92,73]; let head=&v[0]; v.push(44); | let mut v=vec![41,92,73]; let head=v[0]; v.push(44); | Copy instead of reference. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
if c = 66 | if c == 66 | Use ==. | MATLAB |
println('world') | println("world") | Double quotes. | Scala |
status: output
value: hello, | status: output
value: hello | Remove comma. | YAML |
handle | handle() | Add parentheses. | Swift |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
INSERT INTO items VALUES ('data',1) | INSERT INTO items (id, status) VALUES ('data',1); | Specify columns. | SQL |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
const index = 1; index = 48; | let index = 1; index = 48; | Cannot reassign const. | JavaScript |
val == '4' | val === 4 | Use strict equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
int[] data = new int[56];
data[56] = 5; | int[] data = new int[56];
if (56 < data.length) data[56] = 5; | Check bounds. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
jwt.sign({{id:22}}, 'secret'); | jwt.sign({{id:22}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<user><name>world</name><name>84</name></user | <user><name>world</name><name>84</name></user> | Add closing >. | XML |
local y = 58 | local y = 58 | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.