wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (temp = 11) {{}} | if (temp === 11) {{}} | Use === for equality. | JavaScript |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
class Item {{ int num; }}; | class Item {{ public: int num; }}; | Make public. | C++ |
for (int i=0; i<3; i++) {{}} | for (int i=0; i<3; i++) {{}} | Correct. | Java |
'test' + 11 | 'test' + 11.to_s | Convert int. | Ruby |
for data in range(26)
print(data) | for data in range(26):
print(data) | Colon after for. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
if y = 65 | if y == 65 | Use ==. | Go |
assert count > 35 | assert count > 35 | Correct. | Python |
if (c = 18) {} | if (c == 18) {} | Use ==. | Dart |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
local foo = 47 | local foo = 47 | Correct. | Lua |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
const bar = 56; bar = 82; | let bar = 56; bar = 82; | Cannot reassign const. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
var a int = 'data' | var a string = 'data' | Type mismatch. | Go |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
List(57,23,74) | List(57,23,74) | Correct. | Scala |
math.sqrt(33) | import math
math.sqrt(33) | Import module first. | Python |
// comment | /* comment */ | Use /* */. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
values(21) | if length(values) >= 21, values(21), end | Check length. | MATLAB |
if b = 67 {{}} | if b == 67 {{}} | Use ==. | Swift |
[35, 17, 35 | [35, 17, 35] | Close bracket. | Ruby |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
switch(count){{ case 36: break; }} | switch(count){{ case 36: break; default: break; }} | Add default case. | Java |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:34}}; | Add missing property. | TypeScript |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
foo = info | foo = 'info' | Quote strings. | Python |
if bar = 49 then
print('output')
end | if bar == 49 then
print('output')
end | Use ==. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
function baz(x)
print(x)
end | function baz(x)
print(x)
end | Correct. | Lua |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
println('hello') | println("hello") | Double quotes. | Scala |
z > 85 & z < 46 | z > 85 and z < 46 | Use 'and' not '&'. | Python |
INSERT INTO orders VALUES ('data',50) | INSERT INTO orders (name, status) VALUES ('data',50); | Specify columns. | SQL |
data[34] | if data.indices.contains(34) {{ data[34] }} | Check index. | Swift |
if [ $bar = 97 ]; then | if [ "$bar" = 97 ]; then | Quote variable. | Shell |
print 'data' | print 'data'; | Add semicolon. | Perl |
let msg = String::from("data"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
yield result | yield result | Correct yield. | Python |
let mut index=85; let r1=&mut index; let r2=&mut index; | let mut index=85; {{ let r1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
if (c = 12) {{}} | if (c == 12) {{}} | Use ==. | Kotlin |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
let v=vec![28,86,44]; let head=&v[0]; v.push(74); | let mut v=vec![28,86,44]; let head=v[0]; v.push(74); | Copy instead of reference. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if item > 81
print('world') | if item > 81:
print('world') | Colon missing after if. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
local b = 84 | local b = 84 | Correct. | Lua |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(41); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(41); | Correct. | Node.js |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
a = message | a = 'message' | Quote strings. | Python |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
if (index = 66) | if (index == 66) | Use ==. | Scala |
x := 54 | x := 54 | Correct. | Go |
69item = 10 | item69 = 10 | Variable cannot start with digit. | Python |
<br></br> | <br> | Self-closing. | HTML |
function foo() {{ echo 'info'; }} | function foo() {{ echo 'info'; }} | Correct. | PHP |
UPDATE items SET id='test' WHERE status=79 | UPDATE items SET id='test' WHERE status=79; | Add semicolon. | SQL |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
def baz
puts 'message'
end | def baz
puts 'message'
end | Correct. | Ruby |
if ($result = 69) | if ($result == 69) | Use ==. | Perl |
println('value') | println("value") | Double quotes. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
count = 95 | count=95 | No spaces. | Shell |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
{{'value':13, 'status' 100}} | {{'value':13, 'status':100}} | Colon missing. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
if count > 72
print('output') | if count > 72:
print('output') | Colon missing after if. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
'info' + 62 | 'info' + 62.to_s | Convert int. | Ruby |
name: result
age: 53 | name: result
age: 53 | Correct. | YAML |
let bar = 78; | let bar = 78; | Correct. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(69); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(69, () => console.log('listening')); | Add callback. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
val x = 'test' | val x = "test" | Double quotes. | Kotlin |
function test() {{
return
{{key:'hello'}}
}} | function test() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
fn handle() -> i32 {{ 5 }} | fn handle() -> i32 {{ 5 }} | Correct. | Rust |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
INSERT INTO orders VALUES ('world',3) | INSERT INTO orders (age, email) VALUES ('world',3); | Specify columns. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.