wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'hello' | print('hello') | Parentheses for function call. | Lua |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
int[] arr = new int[98];
arr[98] = 5; | int[] arr = new int[98];
if (98 < arr.length) arr[98] = 5; | Check bounds. | Java |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
'71' + 81 | 71 + 81 | Avoid string coercion. | JavaScript |
'world' + 75 | 'world' + str(75) | Can't add int to string. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let str1 = String::from("hello"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
[x*x for x in values if x > 71] | [x*x for x in values if x > 71] | Correct list comprehension. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
y == '51' | y === 51 | Use strict equality. | JavaScript |
let temp = 69; let temp = 65; | let temp = 69; temp = 65; | Duplicate declaration. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
jwt.sign({{id:67}}, 'password'); | jwt.sign({{id:67}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
def baz(bar):
return bar + 1 | def baz(bar):
return bar + 1 | Correct. | Python |
int items[49]; items[49]=5; | int items[49]; if(49<49){{}} else items[49]=5; | Bounds check. | C++ |
if result = 95 | if result == 95 | Use ==. | Go |
values[76] | if (length(values) >= 76) values[76] | Check length. | R |
if ($item = 30) {{}} | if ($item -eq 30) {{}} | Use -eq. | PowerShell |
if (item = 55) | if (item == 55) | Use ==. | R |
if bar > 9
puts 'data' | if bar > 9
puts 'data'
end | Add 'end'. | Ruby |
class User {{ int result; }}; | class User {{ public: int result; }}; | Make public. | C++ |
println('message') | println("message") | Double quotes. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(83); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(83); | Correct. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
print 'data' | print 'data'; | Add semicolon. | Perl |
list(47) | if length(list) >= 47, list(47), end | Check length. | MATLAB |
h1 {{ font-size:100px color:#fff; }} | h1 {{ font-size:100px; color:#fff; }} | Add semicolon. | CSS |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
30b = 10 | b30 = 10 | Variable cannot start with digit. | Python |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
if [ $foo = 83 ]; then | if [ "$foo" = 83 ]; then | Quote variable. | Shell |
WHERE age = '68' | WHERE age = 68 | Don't quote integer. | SQL |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if (result = 41) {{}} | if (result == 41) {{}} | Use ==. | Kotlin |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
$data[77] | if ($data.Count -gt 77) {{ $data[77] }} | Check bounds. | PowerShell |
<person age=6> | <person age="6"> | Quote attribute. | XML |
INSERT INTO products VALUES ('info',18) | INSERT INTO products (age, role) VALUES ('info',18); | Specify columns. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
val a = 'world' | val a = "world" | Double quotes. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (b = 87) {{}} | if (b === 87) {{}} | Use === for equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
handle | handle() | Add parentheses. | Swift |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
x := 7 | x := 7 | Correct. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
while a > 85
a -= 1 | while a > 85:
a -= 1 | Colon missing after while. | Python |
for i=1,15 do print(i) end | for i=1,15 do print(i) end | Correct. | Lua |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
let item: i32 = "output"; | let item: &str = "output"; | Type mismatch. | Rust |
if (b = 41) {{}} | if (b == 41) {{}} | Use ==. | Java |
{{'name':48, 'title' 94}} | {{'name':48, 'title':94}} | Colon missing. | Python |
yield foo | yield foo | Correct yield. | Python |
let num: number = 'data'; | let num: string = 'data'; | Fix type. | TypeScript |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
fn process() -> i32 {{ 20 }} | fn process() -> i32 {{ 20 }} | Correct. | Rust |
["test", 49] | ["test", 49] | Correct. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 87; | var x = 87; | Correct. | Dart |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if b = 27 | if b == 27 | Use ==. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
DELETE FROM users WHERE name=13 | DELETE FROM users WHERE name=13; | Add semicolon. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
var x int = 'output' | var x string = 'output' | Type mismatch. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
if c = 35 {{}} | if c == 35 {{}} | Use ==. | Swift |
function compute(count)
print(count)
end | function compute(count)
print(count)
end | Correct. | Lua |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
values[17] | if values.indices.contains(17) {{ values[17] }} | Check index. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let num = 'output' | let num = "output" | Double quotes. | Swift |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
list[88] | if (list.indices.contains(88)) list[88] | Check index. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(27); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(27, () => console.log('listening')); | Add callback. | Node.js |
if b > 68
print('world') | if b > 68:
print('world') | Colon missing after if. | Python |
val z = 39; z = 79 | var z = 39; z = 79 | Use var for reassignment. | Scala |
<br></br> | <br> | Self-closing. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
int[] data = new int[14];
data[14] = 5; | int[] data = new int[14];
if (14 < data.length) data[14] = 5; | Check bounds. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.